Reputation: 31
In this tutorial to use SQLite with PouchDB, the cordova plugin used is cordova-plugin-sqlite-2
. Meanwhile in another tutorial to use SQLite in Ionic, the cordova plugin used is cordova-sqlite-storage
.
What's actually the difference between the two plugins?
Is it possible to use cordova-sqlite-storage
with PouchDB instead of cordova-plugin-sqlite-2
?
And is it possible to use cordova-sqlite-plugin-2
when I want to work with Ionic 5 Native SQLite plugin (as the 2nd tutorial)?
UPDATE:
I tried creating an app that uses PouchDB and I installed cordova-sqlite-storage
plugin instead of cordova-plugin-sqlite-2
because I want to use Ionic Native SQLite at the same time. When the app launches, I get an error as below:
ERROR Error: Uncaught (in promise): {"status":500,"name":"web_sql_went_bad","message":"unknown","reason":"Invalid database handle"}
at resolvePromise (zone-evergreen.js:797:1)
at resolvePromise (zone-evergreen.js:754:1)
at zone-evergreen.js:858:1
at ZoneDelegate.invokeTask (zone-evergreen.js:391:1)
at Object.onInvokeTask (core.js:34182:1)
at ZoneDelegate.invokeTask (zone-evergreen.js:390:1)
at Zone.runTask (zone-evergreen.js:168:1)
I have also installed pouchdb-adapter-cordova-sqlite
in my project. According to pouchdb-adapter-cordova-sqlite, it should work with cordova-sqlite-storage
as well as stated;
PouchDB adapter using native Cordova SQLite as its backing store. It works with any one of the following Cordova plugins:
- Cordova-sqlite-storage
- cordova-plugin-sqlite-2
- cordova-plugin-websql
Why did I get that error when I switched to using cordova-sqlite-storage
?
Upvotes: 1
Views: 885
Reputation: 31
Make sure to have only ONE of the plugins.
The error that I got seems to be caused by both plugins existing inside the package.json
. I thought I've removed it by using the ionic cordova plugin rm cordova-plugin-sqlite-2
but when I removed and added the platform again, and run ionic cordova run android -l
, the error still showed up and inside the package.json, apparently cordova-plugin-sqlite-2
was still available.
Checked inside the config.xml
and removed it from there, removed and added the platform, error disappeared.
Upvotes: 2