Registry / database / strato-db

strato-db

JSON →
library3.11.1jsnpmunverified

Strato-DB is a NoSQL-hybrid database for Node.js (≥16.4) that combines schemaless JSON storage with traditional SQLite, adding optional Event Sourcing. Current version 3.11.1 is used in production with multi-GB databases and <1ms query times when well-indexed. Classes include DB, JsonModel, EventSourcingDB, ESModel, and EventQueue. It ships TypeScript definitions for type-checked CRUD. Alternatives like better-sqlite3 offer raw SQL access, while Strato-DB provides a higher-level API with event sourcing patterns. Released under MIT.

npm install strato-db
INSTALL
IMPORT
SIG · STRATO-DB
S
strato-db
databasejavascriptv3.11.1
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.

DB
import { DB } from 'strato-db'
const DB = require('strato-db').DB
ESM-only. No default export; named imports required.
JsonModel
import { JsonModel } from 'strato-db'
import JsonModel from 'strato-db'
Named export, not default.
EventSourcingDB
import { EventSourcingDB } from 'strato-db'
Named export, commonly used with ESModel.

Creates an in-memory SQLite DB, registers a JsonModel, inserts and searches a record.

import { DB, JsonModel } from 'strato-db'; const db = new DB({ file: ':memory:', verbose: false }); class Things extends JsonModel { constructor(options) { super({ ...options, name: 'things', columns: { id: { type: 'INTEGER' }, count: { type: 'INTEGER', index: 'SPARSE' }, }, }); } } db.addModel(Things); async function main() { await db.store.things.set({ id: 1, name: 'example', count: 42 }); const items = await db.store.things.search({ count: 42 }); console.log(items); } main().catch(console.error);
Debug
Known issues
breakingv2 to v3 changed from CJS to ESM. require() no longer works.
fix
Use import statements instead of require.
affects: >=3.0.0
breakingv3 removed the default export; all exports are now named.
fix
Import specific symbols: import { DB, JsonModel } from 'strato-db'
affects: >=3.0.0
deprecatedThe 'verbose' option may be deprecated in future versions; logging is not officially supported.
fix
Avoid relying on verbose output; implement custom logging.
affects: >=3.0.0
gotchaEventSourcingDB does not support multi-process locking; duplicate work may occur.
fix
Use a single process or implement external locking for event queue.
affects: *
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Using ESM import in a CommonJS project without type: module.
fix
Add "type": "module" to package.json or use .mjs extension.
TypeError: strato_db_1.default is not a constructor
Trying to use default import (import DB from 'strato-db') which was removed in v3.
fix
Use named import: import { DB } from 'strato-db'
Error: SQLITE_ERROR: table things already exists
Calling db.addModel(Things) after the table was already created with a different model.
fix
Ensure each model has a unique name, or use migrations to handle schema changes.
Upgrade
Version history
3.11.1latest on npm
Audit
Dependencies
better-sqlite3optionalSQLite engine used under the hood
Agent activity
23 hits · last 30 days
node
20
Meta
2
OpenAI (training)
1
Resources
strato-db — npm install strato-db · libregistry