The `foundationdb` package provides Node.js bindings for interacting with the FoundationDB distributed transactional key-value store. It is currently at version 2.0.1 and appears to have an active release cadence, with several recent updates following its 1.0.0 and 2.0.0 major releases. This library offers low-level access to FoundationDB's core features, including ACID transactions, range reads, key selectors, watches, and directory management. A key differentiator is its direct C++ binding approach, requiring users to install the FoundationDB client library separately on their system. It includes robust support for tuple and JSON encoding for keys and values, simplifying data serialization and deserialization within transactions. The library mandates setting the API version prior to opening a database connection, and it is compatible with FoundationDB server versions 6.2.0 and newer.
npm install foundationdbVerified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to FoundationDB, creating a directory, configuring key/value encoding, performing a transactional write, and reading data using the promise-based API.
Download and install the appropriate FoundationDB client library for your operating system and architecture from foundationdb.org/download/. Ensure the library is discoverable by your system's dynamic linker (e.g., in PATH on Windows, LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on macOS).
Ensure `fdb.setAPIVersion(version)` is placed at the absolute start of your application's bootstrap logic, prior to any `fdb.open()` calls or other API interactions. If you have multiple calls from different parts of your code, consolidate them.
Windows users should currently avoid this library or use a Linux/macOS environment. Monitor the FoundationDB forums and GitHub issues for updates on Windows support.
Add `export DYLD_LIBRARY_PATH=/usr/local/lib` to your shell configuration file and restart your terminal or shell session for changes to take effect.
Ensure your FoundationDB cluster is running version 6.2.0 or newer. Verify that the `setAPIVersion` call matches a supported client API version for your specific server version.
Install the FoundationDB client library for your OS and architecture from foundationdb.org/download/. On Linux, ensure `libfdb_c.so` is in a standard path like `/usr/local/lib` or `LD_LIBRARY_PATH` is set. On macOS, check `DYLD_LIBRARY_PATH`. On Windows, ensure `fdb_c.dll` is in a directory listed in your system's `PATH` environment variable.
Identify all calls to `fdb.setAPIVersion()` and consolidate them into a single invocation at the absolute entry point of your application before any other FoundationDB API usage.
In an ESM context, use `import * as fdb from 'foundationdb';` to correctly import all exports from the CommonJS module. If using CommonJS, `const fdb = require('foundationdb');` is correct.