Registry / storage / dbdjs.db

dbdjs.db

JSON →
library2.0.2jsnpmunverified

dbdjs.db is a JSON-based database library for Node.js, optimized for speed and ease of use, commonly used with Discord bots (dbd.js, aoi.js). Version 2.0.2 is the current stable release. It provides a simple key-value store with tables, file-based persistence, in-memory caching, and configurable save intervals. Types included. Alternatives like enmap or quick.db offer similar functionality.

npm install dbdjs.db
INSTALL
IMPORT
SIG · DBDJS.DB
D
dbdjs.db
storagejavascriptv2.0.2
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 'dbdjs.db'
✗ const DBDJSDB = require('dbdjs.db'); const db = new DBDJSDB.Database(...)
ESM is supported. CommonJS also works but requires accessing Database as a property of the default export.
default export
✓ import DBDJSDB from 'dbdjs.db'
✗ const DBDJSDB = require('dbdjs.db').default
The package does not have a default export. Use named exports instead.
DatabaseOptions
✓ import type { DatabaseOptions } from 'dbdjs.db'
✗ const { DatabaseOptions } = require('dbdjs.db')
DatabaseOptions is a TypeScript type, not a runtime value.

Demonstrates creating a database instance, connecting, setting, getting, and deleting data.

import { Database } from 'dbdjs.db'; const db = new Database({ path: './database', tables: [{ name: 'users' }], }); db.once('ready', async () => { console.log('Database ready!'); await db.set('users', 'key1', 'value1'); const data = await db.get('users', 'key1'); console.log(data); // { key: 'key1', value: 'value1' } await db.delete('users', 'key1'); db.destroy(); }); db.connect();
Debug
Known issues
gotchaThe connect() method is asynchronous; events like 'ready' should be used to ensure database is ready before operations.
fix
Listen for the 'ready' event before performing read/write operations.
affects: >=2.0.0
gotchaDefault file extension is '.sql', not '.json'.
fix
Set extension option to '.json' if you prefer JSON files.
affects: >=2.0.0
gotchamaxFileData (default 50000) limits entries per file; if exceeded, data may be split into multiple files.
fix
Adjust maxFileData or manage table sizes.
affects: >=2.0.0
gotchacache option (default 3000) limits in-memory cache size; old entries may be evicted.
fix
Increase cache size or use force option for critical data.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'dbdjs.db'
Package not installed or not in node_modules.
fix
Run 'npm install dbdjs.db' in your project directory.
TypeError: db.set is not a function
Database instance not properly initialized or not connected.
fix
Ensure you call 'new Database(...)' and wait for the 'ready' event.
Error: Table "test" does not exist
Attempted to use a table that was not defined in the constructor options.
fix
Add the table to the 'tables' array when creating the Database instance.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources