Registry / database / pouchdb-adapter-cordova-sqlite

pouchdb-adapter-cordova-sqlite

JSON →
library2.0.8jsnpmunverified

A PouchDB adapter that uses native Cordova SQLite as its backing store, providing persistent local storage for hybrid mobile apps. Version 2.0.8 is current; the package is in maintenance mode with infrequent updates. It supports multiple Cordova SQLite plugins (cordova-sqlite-storage, cordova-plugin-sqlite-2, cordova-plugin-websql) and falls back to WebSQL if no SQLite plugin is detected. The adapter was extracted from PouchDB core in v6.0.0 to simplify configuration. Requires manual registration via PouchDB.plugin() and must be used within the Cordova deviceready event. Key differentiator: native SQLite performance vs. bundled WebSQL, with configurable storage options (location, androidDatabaseImplementation).

npm install pouchdb-adapter-cordova-sqlite
INSTALL
IMPORT
SIG · POUCHDB-ADAPTER-CO
P
pouchdb-adapter-cordova-sqlite
databasejavascriptv2.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import PouchAdapter from 'pouchdb-adapter-cordova-sqlite';
const PouchAdapter = require('pouchdb-adapter-cordova-sqlite').default;
ESM default export; works with both import and require.
PouchDB
import PouchDB from 'pouchdb-core'; PouchDB.plugin(PouchAdapter);
import PouchDB from 'pouchdb';
PouchDB must be installed separately; the adapter does not re-export PouchDB.
PouchDB with adapter option
const db = new PouchDB('mydb.db', {adapter: 'cordova-sqlite'});
const db = new PouchDB('mydb.db', {adapter: 'sqlite'});
The adapter name is 'cordova-sqlite' not 'sqlite'.

Shows how to register the adapter with PouchDB and create/open a SQLite database inside Cordova's deviceready event.

// Install: npm install pouchdb-core pouchdb-adapter-cordova-sqlite // Must run inside Cordova deviceready event document.addEventListener('deviceready', function() { // ESM import PouchDB from 'pouchdb-core'; import PouchAdapter from 'pouchdb-adapter-cordova-sqlite'; PouchDB.plugin(PouchAdapter); const db = new PouchDB('myapp.db', { adapter: 'cordova-sqlite' }); db.put({ _id: 'test', data: 'hello' }).then(() => { return db.get('test'); }).then(doc => { console.log('Document:', doc); }).catch(err => console.error(err)); });
Debug
Known issues
breakingPouchDB v6.0.0 removed built-in Cordova SQLite support; this adapter must be installed separately.
fix
Use this adapter plugin with PouchDB v6+.
affects: >=6.0.0
gotchaAdapter must be registered via PouchDB.plugin() before creating a database with {adapter:'cordova-sqlite'}.
fix
Call PouchDB.plugin(require('pouchdb-adapter-cordova-sqlite')) before new PouchDB.
affects: >=0.0.0
gotchaDatabase operations must occur inside the Cordova deviceready event, not earlier.
fix
Wrap PouchDB code in document.addEventListener('deviceready', function() { ... });
affects: >=0.0.0
deprecatedUsing the legacy '_pouch_' database name prefix requires setting cordovaSqlitePlugin.use_prefix = true before registering.
fix
Set the use_prefix flag as shown in README or switch to non-prefixed names.
affects: >=2.0.0
gotchaFalls back to WebSQL if no Cordova SQLite plugin is detected; performance and features may differ.
fix
Verify window.sqlitePlugin exists or install a SQLite plugin.
affects: >=0.0.0
breakingAdapter name is 'cordova-sqlite', not 'websql' or 'sqlite'.
fix
Use {adapter: 'cordova-sqlite'} in options.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Can't find variable: cordova
Code executed before deviceready event.
fix
Move PouchDB code inside document.addEventListener('deviceready', ...).
Error: adapter is not a function
PouchDB.plugin() not called correctly.
fix
Ensure PouchDB.plugin(require('pouchdb-adapter-cordova-sqlite')) is used before creating database.
Error: No adapter found for cordova-sqlite
Adapter not registered with PouchDB.
fix
Call PouchDB.plugin(adapter) with the correct adapter module.
TypeError: Cannot read property 'openDatabase' of undefined
WebSQL fallback not available outside Cordova.
fix
Run inside Cordova webview with a SQLite plugin installed.
Upgrade
Version history
2.0.8latest on npm
Audit
Dependencies
pouchdb-corerequiredPouchDB core library is required
Agent activity
6 hits · last 30 days
node
6
Resources
pouchdb-adapter-cordova-sqlite — npm install pouchdb-adapter-cordova-sqlite · libregistry