node-lmdb provides a high-performance Node.js binding to LMDB (Lightning Memory-Mapped Database), a transactional key-value store renowned for its speed and efficiency. It operates as an in-process, zero-copy database, eliminating the overhead of socket communication. The library supports transactions, multiple databases within a single environment, and is designed for multi-threaded and multi-process use, offering crash-proof persistence. The current stable version is 0.10.1, with releases occurring periodically to address bugs and introduce features. Its key differentiators include direct memory-mapped access, support for binary and string values via Node.js Buffers, and an API designed to align with JavaScript conventions while maintaining parity with the underlying LMDB C API. It's suitable for applications requiring extremely fast, durable, local data storage.
npm install node-lmdbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize an LMDB environment, open a database, perform read and write operations within a transaction, and then properly close resources. It covers storing strings and binary data, and includes cleanup.
Ensure every call to `env.beginTxn()` is paired with a `txn.commit()` or `txn.abort()` in a `try...finally` block to guarantee transaction closure.
Review the changelog or GitHub releases for specific breaking changes if migrating from older versions. Update to `node-lmdb@^0.10.0` and adapt code as necessary.
Carefully estimate your maximum database size requirements and set `mapSize` generously. It is advisable to set it larger than strictly necessary, as resizing often requires closing and reopening the environment.
Ensure your development and deployment environments have `node-gyp` prerequisites installed (Python 3, build tools like GCC/Clang or Visual C++). Consult the `node-gyp` documentation for specific OS requirements.
Increase the `mapSize` property in `env.open()` to a sufficiently large value. You may need to close and reopen the environment for the change to take effect.
Ensure all database operations are performed within the scope of an active transaction. Do not reuse `Txn` objects after `commit()` or `abort()`. Create a new transaction for each logical unit of work.
This is often expected behavior. Check the return value of `get*()` methods, which will typically be `null` or `undefined` if the key is not found. Handle these cases gracefully in your application logic.
Install necessary build tools for your operating system. For Windows, install Visual Studio Build Tools. For Linux, install `build-essential` (Debian/Ubuntu) or `Development Tools` (Fedora/RHEL). Ensure Python 3 is installed and configured correctly for `node-gyp`.
No dependency data recorded yet.