{"id":40810,"library":"dbdjs.db","title":"dbdjs.db","description":"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.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","dbd.js","dbdjs","dbd","aoi.js","aoi","json","database","discord","typescript"],"install":[{"cmd":"npm install dbdjs.db","lang":"bash","label":"npm"},{"cmd":"yarn add dbdjs.db","lang":"bash","label":"yarn"},{"cmd":"pnpm add dbdjs.db","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM is supported. CommonJS also works but requires accessing Database as a property of the default export.","wrong":"const DBDJSDB = require('dbdjs.db'); const db = new DBDJSDB.Database(...)","symbol":"Database","correct":"import { Database } from 'dbdjs.db'"},{"note":"The package does not have a default export. Use named exports instead.","wrong":"const DBDJSDB = require('dbdjs.db').default","symbol":"default export","correct":"import DBDJSDB from 'dbdjs.db'"},{"note":"DatabaseOptions is a TypeScript type, not a runtime value.","wrong":"const { DatabaseOptions } = require('dbdjs.db')","symbol":"DatabaseOptions","correct":"import type { DatabaseOptions } from 'dbdjs.db'"}],"quickstart":{"code":"import { Database } from 'dbdjs.db';\n\nconst db = new Database({\n  path: './database',\n  tables: [{ name: 'users' }],\n});\n\ndb.once('ready', async () => {\n  console.log('Database ready!');\n  await db.set('users', 'key1', 'value1');\n  const data = await db.get('users', 'key1');\n  console.log(data); // { key: 'key1', value: 'value1' }\n  await db.delete('users', 'key1');\n  db.destroy();\n});\n\ndb.connect();","lang":"typescript","description":"Demonstrates creating a database instance, connecting, setting, getting, and deleting data."},"warnings":[{"fix":"Listen for the 'ready' event before performing read/write operations.","message":"The connect() method is asynchronous; events like 'ready' should be used to ensure database is ready before operations.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Set extension option to '.json' if you prefer JSON files.","message":"Default file extension is '.sql', not '.json'.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Adjust maxFileData or manage table sizes.","message":"maxFileData (default 50000) limits entries per file; if exceeded, data may be split into multiple files.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Increase cache size or use force option for critical data.","message":"cache option (default 3000) limits in-memory cache size; old entries may be evicted.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.2':27 'altern':57 'aoi':70 'aoi.js':25,69 'base':7,45 'bot':23 'cach':50 'common':19 'configur':52 'current':30 'databas':8,72 'dbd':68 'dbd.js':24,66 'dbdjs':67 'dbdjs.db':1,2 'discord':22,73 'eas':16 'enmap':59 'file':44 'file-bas':43 'function':64 'in-memori':47 'includ':56 'interv':54 'javascript':65 'json':6,71 'json-bas':5 'key':38 'key-valu':37 'librari':9 'like':58 'memori':49 'node.js':11 'offer':62 'optim':12 'persist':46 'provid':34 'quick.db':61 'releas':32 'save':53 'similar':63 'simpl':36 'speed':14 'stabl':31 'store':40 'tabl':42 'type':55 'typescript':74 'use':18,20 'valu':39 'version':26","created_at":"2026-06-04T18:49:21.723751+00:00","updated_at":"2026-06-04T18:49:21.723751+00:00","problems":[{"fix":"Run 'npm install dbdjs.db' in your project directory.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'dbdjs.db'"},{"fix":"Ensure you call 'new Database(...)' and wait for the 'ready' event.","cause":"Database instance not properly initialized or not connected.","error":"TypeError: db.set is not a function"},{"fix":"Add the table to the 'tables' array when creating the Database instance.","cause":"Attempted to use a table that was not defined in the constructor options.","error":"Error: Table \"test\" does not exist"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"dbdjs.db","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"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}}