{"id":24979,"library":"bar-db","title":"bar-db","description":"Beyond All Reason Database (bar-db) is a lightweight, typed database library for Node.js and browser environments, currently at v6.4.1. It provides a simple key-value store with optional schema validation, focusing on ease of use and TypeScript integration. Key differentiators include zero dependencies, built-in JSON-based persistence, and support for async/await patterns. The library is actively maintained with a monthly release cadence.","status":"active","version":"6.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/Jazcash/bar-db","tags":["javascript","typescript"],"install":[{"cmd":"npm install bar-db","lang":"bash","label":"npm"},{"cmd":"yarn add bar-db","lang":"bash","label":"yarn"},{"cmd":"pnpm add bar-db","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v6. Requires Node >=12 or a bundler. TypeScript types included.","wrong":"const Database = require('bar-db')","symbol":"Database","correct":"import { Database } from 'bar-db'"},{"note":"Use for defining typed schemas. Not exported as default.","symbol":"Schema","correct":"import { Schema } from 'bar-db'"},{"note":"TypeScript users should import types explicitly for best tree-shaking.","symbol":"type DBEntry","correct":"import type { DBEntry } from 'bar-db'"}],"quickstart":{"code":"import { Database } from 'bar-db';\n\nconst db = new Database({ path: './data.json' });\nawait db.init();\n\n// Insert a record\nawait db.set('user:1', { name: 'Alice', age: 30 });\n\n// Retrieve a record\nconst user = await db.get('user:1');\nconsole.log(user); // { name: 'Alice', age: 30 }\n\n// Delete a record\nawait db.delete('user:1');\n\n// List all keys\nconst keys = await db.keys();\nconsole.log(keys); // []","lang":"typescript","description":"Initialize a bar-db database, insert, retrieve, delete a record, and list keys."},"warnings":[{"fix":"Use await or .then() on all Database method calls. For sync usage, stick to v5.x.","message":"As of v6.0.0, all methods are async and return Promises. Sync API removed.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Replace `import Database from 'bar-db'` with `import { Database } from 'bar-db'`.","message":"v6.0.0 removed the default export; use named exports instead.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Pass an absolute path or use path.resolve().","message":"Database path is relative to process.cwd() in Node.js; always use an absolute path for consistency.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Remove calls to .save() and .load(); .init() handles persistence automatically.","message":".save() and .load() methods are deprecated since v6.4.0. Use .init() for automatic persistence.","severity":"deprecated","affected_versions":">=6.4.0"}],"env_vars":null,"search_vec":"'activ':65 'async/await':60 'bar':2,9 'bar-db':1,8 'base':55 'beyond':4 'browser':20 'built':51 'built-in':50 'cadenc':71 'current':22 'databas':7,15 'db':3,10 'depend':49 'differenti':46 'eas':39 'environ':21 'focus':37 'includ':47 'integr':44 'javascript':72 'json':54 'json-bas':53 'key':30,45 'key-valu':29 'librari':16,63 'lightweight':13 'maintain':66 'month':69 'node.js':18 'option':34 'pattern':61 'persist':56 'provid':26 'reason':6 'releas':70 'schema':35 'simpl':28 'store':32 'support':58 'type':14 'typescript':43,73 'use':41 'v6.4.1':24 'valid':36 'valu':31 'zero':48","created_at":"2026-05-01T13:42:23.500866+00:00","updated_at":"2026-05-01T13:42:23.500866+00:00","problems":[{"fix":"Switch to import { Database } from 'bar-db' and ensure your project uses ESM.","cause":"Using require('bar-db') with v6 where only named ESM exports exist.","error":"TypeError: db.set is not a function"},{"fix":"Provide an absolute path or ensure the parent directory exists before init.","cause":"Database path is relative and the directory does not exist.","error":"Error: ENOENT: no such file or directory, open './data.json'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Jazcash/bar-db","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/bar-db","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}