ionic2-tutorial-pouchdb icon indicating copy to clipboard operation
ionic2-tutorial-pouchdb copied to clipboard

Where is the SQLite adaptor?

Open andy008 opened this issue 8 years ago • 7 comments

Is this article misnamed, or am I missing something?

When you set pouchDB it's using the WebSQL adaptor, not SQLite.

andy008 avatar Mar 02 '17 02:03 andy008

When I made the tutorial I was using a version of PouchDB before 6.0.0. In that version, PouchDB would automatically select the SQLite adapter if you had that installed. Since 6.0.0. this is no longer the case.

I will update the tutorial this week, but in the meantime, have a look at the first comment by Nolan Lawson on the tutorial: http://disq.us/p/1f65qim

ashteya avatar Mar 02 '17 08:03 ashteya

Makes sense. Unfortunately, I've yet to see a working Ionic 2 example using the pouchdb-adapter-cordova-sqlite plugin. I gave it a good try but it kept throwing errors about expecting the location to be set - but there was no option exposed to pouchDB to set it.

andy008 avatar Mar 02 '17 12:03 andy008

@andy008 and @ashteya same issue...!!!

alejo8591 avatar Mar 21 '17 09:03 alejo8591

The issue can be solved with the official PouchDB developer plugin: cordova-plugin-sqlite-2

alejo8591 avatar Mar 21 '17 09:03 alejo8591

No, Pouch has withdrawn built-in support for SQLite. You need an adaptor to connect to the Cordova Plugin, which exists but I could not get to work with Pouch. See https://libraries.io/npm/pouchdb-adapter-cordova-sqlite

The examples are all pre-Ionic 2, and although I got the plug-in to install, when called it complains about various missing parameters which cannot be passed through.

andy008 avatar Mar 21 '17 21:03 andy008

@andy008 I updated the tutorial a few days ago and tested it on iOS and can confirm that it worked. Can you let me know what exactly went wrong for you?

ashteya avatar Mar 21 '17 21:03 ashteya

@andy008 yep!, In historical notes they affirm it; Is decoupled from the PouchDB core:

Until PouchDB 6.0.0, PouchDB's regular websql adapter supported the Cordova SQLite Plugin automatically. However, the PouchDB team found this to be confusing, error-prone, and difficult to configure, which is why it was extracted into a separate plugin. You can read details in PouchDB's list of breaking changes.

So what I did I installed pouchdb-adapter-cordova-sqlite and how to plug in SQLite cordova-plugin-sqlite-2, it works for iOS and Android >= API 16.

On the other hand probe with the other suggestion plugins, but I didn't work, only with the one that maintains the developer of PouchDB.

Regards!

alejo8591 avatar Mar 21 '17 22:03 alejo8591