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
✓ const sqliteSearch = require('sqlite-search');
✗ import sqliteSearch from 'sqlite-search';
The package does not ship TypeScript definitions and uses CommonJS. Default import via ESM may fail without interop.
default (as function)
✓ sqliteSearch(opts, (err, searcher) => { ... });
✗ new sqliteSearch(opts, callback);
The module exports a constructor-like function that takes options and callback, not a class. Do not use 'new'.
instance.createWriteStream
✓ const ws = searcher.createWriteStream();
✗ const ws = sqliteSearch.createWriteStream(opts);
createWriteStream is a method on the searcher instance, not on the module itself.
instance.createSearchStream
✓ const rs = searcher.createSearchStream({ field: 'title', query: 'hello' });
✗ const rs = searcher.createSearchStream({ query: 'hello' });
'field' is required for FTS search. Missing it will cause an error.
Creates an indexed SQLite FTS table, inserts two documents, and searches for 'hello' across the title field.
const sqliteSearch = require('sqlite-search');
const path = require('path');
const dbPath = path.join(__dirname, 'search.db');
sqliteSearch({ path: dbPath, columns: ['title'], primaryKey: 'id' }, (err, searcher) => {
if (err) throw err;
// Write objects
const ws = searcher.createWriteStream();
ws.write({ id: 1, title: 'hello world' });
ws.write({ id: 2, title: 'foo bar' });
ws.end();
// Search
const rs = searcher.createSearchStream({ field: 'title', query: 'hello' });
rs.on('data', (result) => console.log(result));
rs.on('error', (err) => console.error(err));
});
Errors
Common errors & fixes
Error: SQLITE_ERROR: no such module: fts3
The SQLite library was compiled without FTS3/FTS4 support.
fixReinstall sqlite3 with full-text search support or use a build with FTS enabled.
Error: Cannot find module 'sqlite3'
sqlite3 is a peer dependency but not installed or failed to compile native addon.
fixRun 'npm install sqlite3' in the project directory.
TypeError: searcher.createSearchStream is not a function
The searcher instance was not properly initialized; likely missing callback or wrong usage.
fixEnsure you call sqliteSearch(opts, callback) and use the searcher inside the callback.
Error: read ECONNRESET
This is a generic network error unrelated to sqlite-search, but may appear if the module is used in an Electron context with node integration.
fixRun the application in a proper Node.js environment, not Electron's renderer process without nodeIntegration.
Audit
Dependencies
sqlite3requiredSQLite database binding used for all database operations