Registry / database / pouchdb-adapter-sqlite-core

pouchdb-adapter-sqlite-core

JSON →
library1.1.2jsnpmunverified

Core adapter for using SQLite as a PouchDB data store. Version 1.1.2 (last release: unknown cadence). This package provides a SQLite-based storage backend for PouchDB, enabling offline-first databases with SQLite as the underlying engine. Unlike LevelDB-based adapters, this adapter leverages SQLite for better performance on mobile and desktop environments, especially on platforms where SQLite is natively available. Requires a SQLite binding (e.g., react-native-sqlite-storage or sql.js) to be provided via the `sqlite` option. Intended for Node.js, React Native, and browser environments with appropriate SQLite libraries.

npm install pouchdb-adapter-sqlite-core
INSTALL
IMPORT
SIG · POUCHDB-ADAPTER-SQ
P
pouchdb-adapter-sqlite-core
databasejavascriptv1.1.2
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 PouchDB from 'pouchdb'
const PouchDB = require('pouchdb')
PouchDB must be imported first; the adapter is registered via PouchDB.plugin().
registerAdapter
import { registerAdapter } from 'pouchdb-adapter-sqlite-core'; PouchDB.plugin(registerAdapter(PouchDB))
const registerAdapter = require('pouchdb-adapter-sqlite-core').registerAdapter
registerAdapter is a function that takes PouchDB as argument and returns a plugin object.
SqliteAdapter
import { SqliteAdapter } from 'pouchdb-adapter-sqlite-core'
SqliteAdapter is the adapter class; typically used via registerAdapter instead of directly.

Shows how to register the SQLite adapter, set a custom SQLite implementation, and perform basic CRUD operations.

import PouchDB from 'pouchdb'; import { registerAdapter } from 'pouchdb-adapter-sqlite-core'; // Register the SQLite adapter with PouchDB PouchDB.plugin(registerAdapter(PouchDB)); // Create a database using the SQLite adapter const db = new PouchDB('mydb', { adapter: 'sqlite' }); // Provide a SQLite implementation (e.g., react-native-sqlite-storage) const SQLite = require('react-native-sqlite-storage'); db.setSqliteImplementation(SQLite); // Use the database normally await db.put({ _id: 'doc1', value: 'test' }); const doc = await db.get('doc1'); console.log(doc); await db.close();
Debug
Known issues
gotchaThe adapter requires an external SQLite implementation to be set via `db.setSqliteImplementation()` or passed as an option. Without it, operations will fail.
fix
Provide a SQLite library instance before using the database. For React Native: import SQLite from 'react-native-sqlite-storage' and call db.setSqliteImplementation(SQLite).
affects: >=1.0.0
gotchaPouchDB's bulk docs operations may silently ignore errors if the adapter is not fully supported. Always check error callbacks.
fix
Use try/catch or error-first callbacks for bulk operations.
affects: >=1.0.0
deprecatedThe `SqliteAdapter` class is not meant to be instantiated directly; use `registerAdapter(PouchDB)` instead.
fix
Always use the registerAdapter function.
affects: >=1.0.0
gotchaDo not use this adapter with the 'sqlite' adapter name if you have multiple SQLite adapters registered; conflicts may occur.
fix
Use a unique adapter name via PouchDB.plugin and specify that name when creating the database.
affects: >=1.0.0
Errors
Common errors & fixes
Error: No SQLite implementation set. Use setSqliteImplementation() or pass sqlite option.
Missing SQLite library initialization.
fix
Call db.setSqliteImplementation(SQLite) with a valid SQLite library instance before any database operation.
TypeError: adapter is not a function
registerAdapter was not called correctly or PouchDB plugin registration missing.
fix
Ensure you call PouchDB.plugin(registerAdapter(PouchDB)) with the correct PouchDB instance.
Error: Cannot find module 'react-native-sqlite-storage'
SQLite library is not installed or not properly linked.
fix
Install the appropriate SQLite package: npm install react-native-sqlite-storage (or other) and link if using React Native < 0.60.
Error: SQLITE_ERROR: no such table: main.pouchdb_metadata
Database schema not created because adapter initialization failed.
fix
Ensure PouchDB.plugin was called before creating the database, and that the SQLite implementation is set.
Error: openDatabase: no such table: main.pouchdb_metadata
Adapter failed to create schema on first open.
fix
Check that the SQLite implementation supports creating tables and that the adapter version matches PouchDB version.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
pouchdb-adapter-utilsrequiredUtility functions for PouchDB adapters
pouchdb-mergerequiredDocument merging logic used by PouchDB
pouchdb-md5requiredMD5 hashing for document IDs
pouchdb-binary-utilsrequiredBinary data handling utilities
pouchdb-collectionsrequiredCollection utilities
Agent activity
4 hits · last 30 days
node
4
Resources
pouchdb-adapter-sqlite-core — npm install pouchdb-adapter-sqlite-core · libregistry