nolanlawson / cordova-plugin-sqlite-2

Native SQLite database API for Cordova/PhoneGap/Ionic, modeled after WebSQL (UNMAINTAINED)
https://nolanlawson.com/2016/04/10/introducing-the-cordova-sqlite-plugin-2/
Apache License 2.0
168 stars 28 forks source link

PouchDB error: you must install a SQLite plugin in order for PouchDB to work on this platform. #75

Closed dhruvsingh50 closed 4 years ago

dhruvsingh50 commented 4 years ago

Hi, I have installed the /cordova-plugin-sqlite-2 but still getting this error.

PouchDB error: you must install a SQLite plugin in order for PouchDB to work on this platform. Options:

if (typeof cordova === 'undefined' || (typeof sqlitePlugin === 'undefined' && typeof openDatabase === 'undefined')) ---> this line is giving error

My code :

    **this.db =  new PouchDB(this.name, {adapter: 'cordova-sqlite'});
    console.log(this.db);**

console output:

app-logs: LogStorage db: PouchDB adapter: "cordova-sqlite" auto_compaction: undefined name: "app-logs" prefix: "pouch" taskqueue: TaskQueue$1 {isReady: true, failed: false, queue: Array(0), db: PouchDB} type: ƒ () __opts: {adapter: "cordova-sqlite", name: "app-logs"} _adapter: "cordova-sqlite" _allDocs: ƒ (opts, callback) _bulkDocs: ƒ (req, reqOpts, callback) _cachedViews: {{"fields":{"pd_index":"asc","pd_type":"asc"}}_countundefined: t} _changes: ƒ (opts) _close: ƒ (callback) _destroy: ƒ (opts, callback) _doCompaction: ƒ (docId, revs, callback) _events: {destroyed: Array(1), closed: ƒ} _get: ƒ (id, opts, callback) _getAttachment: ƒ (docId, attachId, attachment, opts, callback) _getLocal: ƒ (id, callback) _getRevisionTree: ƒ (docId, callback) _id: ƒ () _info: ƒ (callback) _maxListeners: undefined _name: "app-logs" _putLocal: ƒ (doc, opts, callback) _remote: false _removeLocal: ƒ (doc, opts, callback) replicate: (...) proto: AbstractPouchDB

marionava commented 4 years ago

I'm having exactly the same issue!

marionava commented 4 years ago

Hi @dhruvsingh50. Do you find any solution for this?

marionava commented 4 years ago

I hope this helps you. SQLite Plugin does not work on the browser. Until I tested it with my iOS device and made a few slight changes to my code it worked perfectly, but only on a real device. This is what I changed on my code:

PouchDB.plugin(SQLitePlugin);
this.db =  new PouchDB(this.name, {
            adapter: 'cordova-sqlite',
            iosDatabaseLocation: 'Library',
            androidDatabaseImplementation: 2
        });
nolanlawson commented 4 years ago

^ This is the right solution. SQLite plugin 2 runs in a WebView, not in a browser.