Registry / database / sqlite-search

sqlite-search

JSON →
library4.1.0jsnpmunverified

Automated SQLite text indexing via streaming interface. Version 4.1.0 is the latest release. Provides a simple API to create an SQLite FTS table, write objects to it via a writable stream, and search against it with a readable stream. Differentiates from raw SQLite usage by abstracting FTS setup and query building, supporting columns, primary key, pagination (limit/offset/since), and custom SQL statements. Uses the `sqlite3` package underneath and streams results in object mode.

npm install sqlite-search
INSTALL
IMPORT
SIG · SQLITE-SEARCH
S
sqlite-search
databasejavascriptv4.1.0
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
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)); });
Debug
Known issues
gotchaThe 'field' option in createSearchStream is required. Omitting it will cause an SQLite error because the query will attempt to MATCH without specifying a column.
fix
Always provide field: 'yourColumnName'.
affects: >=0.0.0
gotchaThe module uses 'sqlite3' which has native bindings. Installation may fail on systems without build tools (Windows, Linux, macOS).
fix
Ensure Python 2.x or 3.x and a C++ compiler are available. Consider using node-gyp rebuild or prebuildify.
affects: >=0.0.0
gotchaThe searcher instance is not a class; do not use the 'new' keyword. Doing so may cause unexpected behavior in Node.js.
fix
Call sqliteSearch(opts, callback) without 'new'.
affects: >=0.0.0
deprecatedThe 'formatType' option with value 'object' follows a custom streaming format. This pattern may be deprecated in future versions as streaming JSON is more common.
fix
Handle raw objects from the stream instead of relying on 'formatType'.
affects: 4.x
Errors
Common errors & fixes
Error: SQLITE_ERROR: no such module: fts3
The SQLite library was compiled without FTS3/FTS4 support.
fix
Reinstall 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.
fix
Run '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.
fix
Ensure 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.
fix
Run the application in a proper Node.js environment, not Electron's renderer process without nodeIntegration.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
sqlite3requiredSQLite database binding used for all database operations
Agent activity
15 hits · last 30 days
node
10
Meta
2
Amazon
1
OpenAI (training)
1
Resources
sqlite-search — npm install sqlite-search · libregistry