Ionic 2 + PouchDB + SQLite Plugin/Adapter not working

Hi!

PouchDB won’t use the sqlite adapter.

My Code

@Injectable
ExampleService:

constructor () {
    this.initDB;
}

initDB() {
    PouchDB.plugin(cordovaSqlitePlugin);
    this.db = new PouchDB('profiles.db', { adapter: 'cordova-sqlite' });
  }

Error: 
"PouchDB error: you must install a SQLite plugin in order for PouchDB to work on this platform. Options:
 - https://github.com/nolanlawson/cordova-plugin-sqlite-2
 - https://github.com/litehelpers/Cordova-sqlite-storage
 - https://github.com/Microsoft/cordova-plugin-websql"

Hints: I have installed the “cordova-plugin-sqlite-2”.
May I need to wait for a deviceready function to fire, but I dont know how? May Somebody can provide me an example code?

1 Like

Yes, you need to wait for device ready, otherwise corova cannot tell if the plugin is available.