Registry / database / bar-db

bar-db

JSON →
library6.4.1jsnpmunverified

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.

npm install bar-db
INSTALL
IMPORT
SIG · BAR-DB
B
bar-db
databasejavascriptv6.4.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.

Database
import { Database } from 'bar-db'
const Database = require('bar-db')
ESM-only since v6. Requires Node >=12 or a bundler. TypeScript types included.
Schema
import { Schema } from 'bar-db'
Use for defining typed schemas. Not exported as default.
type DBEntry
import type { DBEntry } from 'bar-db'
TypeScript users should import types explicitly for best tree-shaking.

Initialize a bar-db database, insert, retrieve, delete a record, and list keys.

import { Database } from 'bar-db'; const db = new Database({ path: './data.json' }); await db.init(); // Insert a record await db.set('user:1', { name: 'Alice', age: 30 }); // Retrieve a record const user = await db.get('user:1'); console.log(user); // { name: 'Alice', age: 30 } // Delete a record await db.delete('user:1'); // List all keys const keys = await db.keys(); console.log(keys); // []
Debug
Known issues
breakingAs of v6.0.0, all methods are async and return Promises. Sync API removed.
fix
Use await or .then() on all Database method calls. For sync usage, stick to v5.x.
affects: >=6.0.0
breakingv6.0.0 removed the default export; use named exports instead.
fix
Replace `import Database from 'bar-db'` with `import { Database } from 'bar-db'`.
affects: >=6.0.0
gotchaDatabase path is relative to process.cwd() in Node.js; always use an absolute path for consistency.
fix
Pass an absolute path or use path.resolve().
affects: >=0.0.0
deprecated.save() and .load() methods are deprecated since v6.4.0. Use .init() for automatic persistence.
fix
Remove calls to .save() and .load(); .init() handles persistence automatically.
affects: >=6.4.0
Errors
Common errors & fixes
TypeError: db.set is not a function
Using require('bar-db') with v6 where only named ESM exports exist.
fix
Switch to import { Database } from 'bar-db' and ensure your project uses ESM.
Error: ENOENT: no such file or directory, open './data.json'
Database path is relative and the directory does not exist.
fix
Provide an absolute path or ensure the parent directory exists before init.
Upgrade
Version history
6.4.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
bar-db — npm install bar-db · libregistry