Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PouchDB in Cordova #5514

Closed
mQckingbird opened this issue Jul 30, 2016 · 4 comments
Closed

PouchDB in Cordova #5514

mQckingbird opened this issue Jul 30, 2016 · 4 comments

Comments

@mQckingbird
Copy link

mQckingbird commented Jul 30, 2016

Hello folks, I was wondering..
Is there a native cordova plugin in the schedule of PouchDB?
https://cordova.apache.org/plugins/

I know it works whit indexeddb, websql, sqlite, but it would be great if there was a PouchDB plugin which can communicate natively with the device. Would it be more faster? More efficient?

@NickColley
Copy link
Contributor

I think actually the fastest storage adapters right now are web storage such as websql, indexeddb but only because having to bridge to native code is costly so the only real benefit of using the sqlite adapter for example is to be able to store lots of data without being effected by any web storage limits you'd find in browsers..

@mQckingbird
Copy link
Author

But having PouchDB in Electron running in LevelDB (which I couldn't make it work), I'd assume it's a change of performance.

I saw that @nolanlawson published something about PouchDB in Java, so there must be a benefit of using native code.
Perhaps I'm wrong, if so.. it would be great an elaborated answer to «Why?»

@nolanlawson
Copy link
Member

@NickColley is correct. The basic explanation as to why "native" is not faster for Cordova is that Cordova can only allow communication between the native layer and the WebView via string-passing. Therefore any binary data has to be serialized as strings and sent between the two, which adds a huge cost. E.g. for large attachments, PouchDB+CordovaSQLite can actually crash the device because it's using too much memory.

Electron on the other hand has implemented a very efficient binary protocol between the Node.js layer and the web layer. This is why it's typically better to use LevelDB/SQLite in Electron rather than IndexedDB/WebSQL. In Cordova, however, the most efficient option is typically IndexedDB/WebSQL.

Also no, there are no plans for a PouchDB Cordova plugin, although there are both cordova-sqlite-storage and SQLite Plugin 2 which PouchDB can use via window.sqlitePlugin. Hope that helps, cheers.

@mQckingbird
Copy link
Author

mQckingbird commented Aug 1, 2016

It helped! Fully understood.
Apparently, someone made Node.js work in a Cordova/Crosswalk App

If you want to check it out: @nolanlawson : nwjs/nw.js#94 (comment)

That can change things in the future.. Running Node in Cordova (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants