overdrive-db
v2.3.2
Published
OverDrive-DB — Embedded document database with ACID transactions, AES-256 encryption, WAL durability and 6 storage engines. The SQLite alternative for Node.js.
Maintainers
Readme
Install
npm install overdrive-dbRequires the native
overdrive.dll(Windows) /liboverdrive.so(Linux) /liboverdrive.dylib(macOS) in thelib/{os}-{arch}/directory. Download from GitHub Releases.
Quick Start
const { OverdriveDb } = require('overdrive-db');
const odb = OverdriveDb.open('myapp.odb');
// Create table
odb.createTable('users');
// Insert
const id = odb.insert('users', { name: 'Alice', age: 30 });
// Get by ID
const doc = odb.get('users', id);
console.log(doc); // { _id: '...', name: 'Alice', age: 30 }
// Query with SQL
const rows = odb.query('SELECT * FROM users WHERE age > 25');
// Update
odb.update('users', id, { age: 31 });
// Delete
odb.delete('users', id);
odb.close();API Reference
Open / Close
const odb = OverdriveDb.open(path); // plain open
const odb = OverdriveDb.open(path, { password: 'secret' }); // encrypted
const odb = OverdriveDb.open(path, { engine: 'RAM' }); // in-memory
odb.sync(); // flush to disk
odb.close(); // release handle
OverdriveDb.version(); // native library version stringTables
odb.createTable('users');
odb.dropTable('users');
odb.listTables(); // → ['users', 'products', ...]
odb.tableExists('users'); // → true / falseCRUD
| Method | Returns | Description |
|--------|---------|-------------|
| odb.insert(table, doc) | string (_id) | Insert a document |
| odb.insertMany(table, docs) | string[] | Insert multiple documents |
| odb.get(table, id) | object \| null | Get document by _id |
| odb.update(table, id, patch) | boolean | Update document by _id |
| odb.delete(table, id) | boolean | Delete document by _id |
| odb.count(table) | number | Count documents in table |
Query
// SQL query — returns array of row objects
const rows = odb.query('SELECT * FROM users ORDER BY age DESC LIMIT 10');
// Full-text search
const results = odb.search('users', 'Alice');Transactions
const { IsolationLevel } = require('overdrive-db');
// Callback style (auto-commit / auto-abort)
odb.transaction(() => {
odb.insert('accounts', { balance: 1000 });
odb.update('accounts', id, { balance: 900 });
}, IsolationLevel.Serializable);
// Manual style
const txn = odb.beginTransaction(IsolationLevel.ReadCommitted);
try {
odb.insert('logs', { event: 'login' });
odb.commitTransaction(txn);
} catch (e) {
odb.abortTransaction(txn);
}Isolation Levels:
| Name | Value |
|------|-------|
| IsolationLevel.ReadUncommitted | 0 |
| IsolationLevel.ReadCommitted | 1 (default) |
| IsolationLevel.RepeatableRead | 2 |
| IsolationLevel.Serializable | 3 |
Integrity Check
const report = odb.verifyIntegrity();
console.log(report); // { status: 'ok', ... }6 Storage Engines
const odb = OverdriveDb.open('app.odb', { engine: 'Disk' }); // default
const odb = OverdriveDb.open('cache.odb', { engine: 'RAM' }); // in-memory
const odb = OverdriveDb.open('vecs.odb', { engine: 'Vector' }); // embeddings
const odb = OverdriveDb.open('ts.odb', { engine: 'Time-Series' }); // metrics
const odb = OverdriveDb.open('g.odb', { engine: 'Graph' }); // social graphs
const odb = OverdriveDb.open('q.odb', { engine: 'Streaming' }); // event queueError Handling
All methods throw an Error on failure. The error message includes the native error code:
try {
odb.insert('nonexistent', { key: 'val' });
} catch (e) {
console.error(e.message); // [overdrive-db] insert failed: ODB-TABLE-001
}More SDKs
OverDrive-DB is available for every major language:
pip install overdrive-db # Python
npm install overdrive-db # Node.js ← you are here
cargo add overdrive-db # Rust
go get github.com/ALL-FOR-ONE-TECH/OverDrive-DB_IncodeSDK/[email protected]