Registry / database / sagdb
library2.3.0jsnpmunverified

Sagdb is a lightweight local JSON database for Node.js, version 2.3.0. It provides a simple key-value store and a table abstraction with CRUD operations, event listeners, and automatic ID generation. The database is file-based, storing data in JSON files. It offers readable JSON output via minify option. Differentiators include built-in dot notation for nested objects, table support with event hooks, and zero external dependencies. Release cadence is irregular; this version is stable but may not see frequent updates.

npm install sagdb
INSTALL
IMPORT
SIG · SAGDB
S
sagdb
databasejavascriptv2.3.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.

Sagdb
✓ import Sagdb from 'sagdb'
✗ const Sagdb = require('sagdb')
ESM default import in TS/ESM; require() returns the module, must access .default or use destructuring
Table
✓ import { Table } from 'sagdb'
✗ import Table from 'sagdb'
Named export; not default export
Sagdb (CJS)
✓ const Sagdb = require('sagdb').default
✗ const Sagdb = require('sagdb')
CJS users must use .default

Shows basic CRUD operations: set, get, update, delete, and add methods with dot notation support.

import Sagdb from 'sagdb'; // Create a database instance const db = new Sagdb({ name: 'mydb', folder: 'data', minify: false }); // Set values db.set('user.name', 'Alice'); db.set('user.age', 30); // Get values console.log(db.get('user.name')); // 'Alice' console.log(db.get('user.age')); // 30 // Update a value using a callback db.update('user.age', (old) => old + 1); console.log(db.get('user.age')); // 31 // Delete a key db.delete('user.age'); console.log(db.get('user.age')); // undefined // Add numeric value db.set('counter', 5); db.add('counter', 3); console.log(db.get('counter')); // 8
Debug
Known issues
gotchaUsing `require('sagdb')` in CommonJS gives an object with `.default` property, not the constructor directly.
fix
Use `const Sagdb = require('sagdb').default;` or switch to ESM `import Sagdb from 'sagdb';`
affects: >=2.0.0
gotchaSetting a Function value throws an error.
fix
Only store serializable values (objects, arrays, strings, numbers, booleans, null).
affects: >=1.0.0
gotchaDatabase folder path uses forward slashes; backslashes are not supported.
fix
Use forward slashes: `folder: 'folder/database'`
affects: >=1.0.0
deprecatedNo explicit deprecations noted; all methods as documented are current.
fix
No action needed.
affects: <=2.3.0
Errors
Common errors & fixes
TypeError: sagdb_1.default is not a constructor
Using incorrect import in CommonJS: `const Sagdb = require('sagdb');` instead of `.default`.
fix
Use `const Sagdb = require('sagdb').default;`
Error: Can't set Function.
Trying to store a function value using `set()`.
fix
Only store serializable values; do not store functions.
Error: value is not a number, can't use add on unset key
Calling `add()` on a key whose value is not a number or doesn't exist.
fix
Ensure the key has a numeric value: `db.set('counter', 0);` then `db.add('counter', 1);`
Error: invalid folder path
Using backslashes in folder path or invalid characters.
fix
Use forward slashes: `folder: 'data/db'`
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
packagesagdb ↗
sagdb — npm install sagdb · libregistry