{"id":41924,"library":"sagdb","title":"Sagdb","description":"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.","status":"active","version":"2.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/imyiit/sagdb","tags":["javascript","database","db","json","local","typescript"],"install":[{"cmd":"npm install sagdb","lang":"bash","label":"npm"},{"cmd":"yarn add sagdb","lang":"bash","label":"yarn"},{"cmd":"pnpm add sagdb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import in TS/ESM; require() returns the module, must access .default or use destructuring","wrong":"const Sagdb = require('sagdb')","symbol":"Sagdb","correct":"import Sagdb from 'sagdb'"},{"note":"Named export; not default export","wrong":"import Table from 'sagdb'","symbol":"Table","correct":"import { Table } from 'sagdb'"},{"note":"CJS users must use .default","wrong":"const Sagdb = require('sagdb')","symbol":"Sagdb (CJS)","correct":"const Sagdb = require('sagdb').default"}],"quickstart":{"code":"import Sagdb from 'sagdb';\n\n// Create a database instance\nconst db = new Sagdb({ name: 'mydb', folder: 'data', minify: false });\n\n// Set values\ndb.set('user.name', 'Alice');\ndb.set('user.age', 30);\n\n// Get values\nconsole.log(db.get('user.name')); // 'Alice'\nconsole.log(db.get('user.age')); // 30\n\n// Update a value using a callback\ndb.update('user.age', (old) => old + 1);\nconsole.log(db.get('user.age')); // 31\n\n// Delete a key\ndb.delete('user.age');\nconsole.log(db.get('user.age')); // undefined\n\n// Add numeric value\ndb.set('counter', 5);\ndb.add('counter', 3);\nconsole.log(db.get('counter')); // 8","lang":"typescript","description":"Shows basic CRUD operations: set, get, update, delete, and add methods with dot notation support."},"warnings":[{"fix":"Use `const Sagdb = require('sagdb').default;` or switch to ESM `import Sagdb from 'sagdb';`","message":"Using `require('sagdb')` in CommonJS gives an object with `.default` property, not the constructor directly.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Only store serializable values (objects, arrays, strings, numbers, booleans, null).","message":"Setting a Function value throws an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use forward slashes: `folder: 'folder/database'`","message":"Database folder path uses forward slashes; backslashes are not supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"No action needed.","message":"No explicit deprecations noted; all methods as documented are current.","severity":"deprecated","affected_versions":"<=2.3.0"}],"env_vars":null,"search_vec":"'2.3.0':12 'abstract':24 'automat':31 'base':39 'built':56 'built-in':55 'cadenc':73 'crud':26 'data':41 'databas':8,35,87 'db':88 'depend':71 'differenti':53 'dot':58 'event':28,66 'extern':70 'file':38,44 'file-bas':37 'frequent':84 'generat':33 'hook':67 'id':32 'includ':54 'irregular':75 'javascript':86 'json':7,43,48,89 'key':18 'key-valu':17 'lightweight':5 'listen':29 'local':6,90 'may':81 'minifi':51 'nest':61 'node.js':10 'notat':59 'object':62 'offer':46 'oper':27 'option':52 'output':49 'provid':14 'readabl':47 'releas':72 'sagdb':1,2 'see':83 'simpl':16 'stabl':79 'store':20,40 'support':64 'tabl':23,63 'typescript':91 'updat':85 'valu':19 'version':11,77 'via':50 'zero':69","created_at":"2026-06-04T18:54:46.062394+00:00","updated_at":"2026-06-04T18:54:46.062394+00:00","problems":[{"fix":"Use `const Sagdb = require('sagdb').default;`","cause":"Using incorrect import in CommonJS: `const Sagdb = require('sagdb');` instead of `.default`.","error":"TypeError: sagdb_1.default is not a constructor"},{"fix":"Only store serializable values; do not store functions.","cause":"Trying to store a function value using `set()`.","error":"Error: Can't set Function."},{"fix":"Ensure the key has a numeric value: `db.set('counter', 0);` then `db.add('counter', 1);`","cause":"Calling `add()` on a key whose value is not a number or doesn't exist.","error":"Error: value is not a number, can't use add on unset key"},{"fix":"Use forward slashes: `folder: 'data/db'`","cause":"Using backslashes in folder path or invalid characters.","error":"Error: invalid folder path"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/imyiit/sagdb#readme","github":"https://github.com/imyiit/sagdb","docs":null,"changelog":null,"pypi":null,"npm":"sagdb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}