{"id":17585,"library":"ejdb","title":"EJDB - Embedded JSON Database","description":"EJDB (Embedded JSON Database) is a lightweight, embedded NoSQL database engine for Node.js, providing a MongoDB-like query language for local JSON document storage. The `ejdb` npm package specifically provides the Node.js bindings for the first generation EJDB engine. This version, `1.2.12-44`, is stable but officially discontinued and has not been updated in over seven years. The project has entirely transitioned to its successor, `ejdb2_node`, which is a complete rewrite. Users should migrate to `ejdb2_node` for active development, maintenance, and new features, including security updates. EJDB v1.x was designed for Node.js versions >=4.0.0 and focused on providing fast, self-contained, file-based JSON document storage with indexing, without requiring a separate server process. Its release cadence was sporadic, with its last publish seven years ago. Its key differentiator was being a high-performance embedded JSON store suitable for small to medium-scale applications where a full-fledged database server was considered overkill.","status":"deprecated","version":"1.2.12-44","language":"javascript","source_language":"en","source_url":"https://github.com/Softmotions/ejdb-node","tags":["javascript","ejdb","tokyocabinet","nosql","database","storage","embedded","mongodb","cli"],"install":[{"cmd":"npm install ejdb","lang":"bash","label":"npm"},{"cmd":"yarn add ejdb","lang":"bash","label":"yarn"},{"cmd":"pnpm add ejdb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package exclusively uses CommonJS modules. ESM 'import' syntax is not supported for this version of EJDB.","wrong":"import EJDB from 'ejdb'","symbol":"EJDB","correct":"const EJDB = require('ejdb')"},{"note":"The Query Language (QL) utility is a static method accessed directly from the main EJDB object after it has been required.","wrong":"import { QL } from 'ejdb'","symbol":"EJDB.QL","correct":"const QL = EJDB.QL"},{"note":"Constants like DEFAULT_OPEN_MODE are properties of the main EJDB object.","wrong":"import { DEFAULT_OPEN_MODE } from 'ejdb'","symbol":"EJDB.DEFAULT_OPEN_MODE","correct":"const { DEFAULT_OPEN_MODE } = EJDB"}],"quickstart":{"code":"const EJDB = require('ejdb');\nconst db = new EJDB();\n\nasync function run() {\n    try {\n        // Open/create a database file named 'my_database.ejdb'\n        // EJDB.DEFAULT_OPEN_MODE includes read/write, create if not exists, and truncate on open if specified.\n        await db.open('my_database.ejdb', EJDB.DEFAULT_OPEN_MODE);\n        console.log('Database opened successfully.');\n\n        // Insert a document into the 'users' collection\n        const userDoc = {\n            name: 'John Doe',\n            age: 42,\n            city: 'Sampleville',\n            interests: ['coding', 'reading', 'hiking']\n        };\n        const oid = await db.insert('users', userDoc);\n        console.log(`Document inserted with OID: ${oid}`);\n\n        // Find documents in the 'users' collection where age is greater than 30\n        // EJDB.QL is used to construct MongoDB-like queries.\n        const query = EJDB.QL('{\"age\": {\"$gt\": 30}}');\n        const cursor = await db.find('users', query);\n        const results = await cursor.toArray();\n        console.log('Found documents:', results);\n\n        // Close the database connection\n        await db.close();\n        console.log('Database closed.');\n    } catch (err) {\n        console.error('An error occurred:', err);\n    }\n}\n\nrun();","lang":"javascript","description":"Demonstrates how to initialize EJDB, open a database file, insert a JSON document, and query for data using a MongoDB-like syntax."},"warnings":[{"fix":"Migrate your application to use the `ejdb2_node` package (https://www.npmjs.com/package/ejdb2_node). This will involve code changes as EJDB2 is a complete rewrite.","message":"The `ejdb` package is officially discontinued and deprecated. All new development, maintenance, and support efforts have shifted to its successor, `ejdb2_node`. Users should plan to migrate to `ejdb2_node` as soon as possible for continued functionality and security.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Ensure you have the necessary build tools installed for `node-gyp` (e.g., Python 2.7, Visual C++ Build Tools on Windows, `build-essential` on Linux). However, due to deprecation, migration to `ejdb2_node` is the recommended long-term solution, as some versions of `ejdb2_node` offer pre-compiled binaries.","message":"As a native Node.js add-on, `ejdb` requires `node-gyp` to compile C++ source code during installation. This process can frequently fail on modern Node.js versions or certain operating systems due to missing build tools (e.g., C++ compilers, Python) or ABI incompatibilities. The package has not been updated in seven years.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Expeditiously migrate to the `ejdb2_node` package, which is actively maintained and supported by the developers.","message":"This package receives no active maintenance, bug fixes, or security updates. Using it in production environments may expose applications to unpatched vulnerabilities or unexpected behavior with newer Node.js versions.","severity":"gotcha","affected_versions":">=1.2.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Install `node-gyp` prerequisites (e.g., `npm install -g node-gyp`, then follow its setup instructions for your OS). For long-term stability, migrate to `ejdb2_node`.","cause":"Installation failed because required C++ build tools are missing or incompatible with your Node.js version/OS.","error":"Error: `node-gyp` failed to rebuild..."},{"fix":"Change your file to use CommonJS (`.js` file without `type: \"module\"`) or refactor your project to use `ejdb2_node` which may offer better ESM compatibility.","cause":"Attempting to use `require()` in an ES module context (`type: \"module\"` in `package.json` or `.mjs` file).","error":"TypeError: require is not a function"},{"fix":"Run `npm install ejdb` again. Check the console output for `node-gyp` errors. If errors persist, ensure build tools are configured or consider migrating to `ejdb2_node`.","cause":"The package was not installed successfully, or Node.js cannot locate the native binding.","error":"Error: Cannot find module 'ejdb'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}