JSON FileSystem Database (jsondbfs) is a NoSQL document database, analogous to MongoDB, designed for Node.js environments. The latest version, 1.0.3, was released in 2017, and the project appears to be no longer actively maintained. It offers fully asynchronous data operations, leveraging the `async` library for parallel execution of accessing and filtering data. It supports two primary drivers: a high-performance 'Memory' driver, which can be configured to periodically flush data to disk for persistence, and a 'Disk' driver that stores all data directly on the filesystem and implements pessimistic transaction locking for data integrity. The package provides a lightweight, file-based database solution with Mongo-style query capabilities via `json-criteria`, but its lack of ongoing development means it may not be suitable for new projects or environments requiring up-to-date dependencies or security patches.
npm install jsondbfsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to connect to a JSON DB FS instance, create/access collections, and perform common CRUD operations (insert, count, update, find, remove) using the asynchronous callback API.
Refer to the `0.4.0` release notes or the latest README for the updated API usage, particularly the `connect` method and collection interaction.
Upgrade to version `0.4.3` or newer to ensure reliable data persistence with the 'memory' driver.
For high-concurrency write operations, consider the 'memory' driver with configured persistence, or carefully manage concurrent access patterns when using the 'disk' driver. Implement robust error handling for lock acquisition failures.
Wrap `jsondbfs` methods with `util.promisify` (Node.js built-in) or a custom Promise wrapper if using async/await syntax is desired. Ensure error handling is consistently applied in callbacks.
The `jsondbfs` module exports an object. Use its `connect` method directly: `const jsondbfs = require('jsondbfs'); jsondbfs.connect(...)`.Ensure the directory specified in the `path` option for `jsondbfs.connect()` exists and has appropriate write permissions for the user running the Node.js application.
All operations on the `database` object must be performed inside the `connect` callback or in code executed only after the `connect` callback has successfully resolved and assigned the `db` instance.
Ensure all collections intended for use are included in the `collections` array passed to `jsondbfs.connect()`.