CroxyDB is a versatile JavaScript database module designed for Node.js environments, currently at version 0.0.26. It provides a straightforward API for managing data with support for various storage backends including JSON files (default), YAML files, and external MongoDB instances. The library offers a familiar key-value store interface with advanced features like dot notation for nested object access (e.g., `db.set("x.y.z", "value")`), array manipulation (`push`, `unpush`, `delByPriority`, `setByPriority`), and robust configuration options for file-based adapters. While in an early pre-1.0 development stage, CroxyDB aims for ease of use and flexibility, allowing developers to switch between local file storage and a remote NoSQL database like MongoDB using a simple adapter system. Its current release cadence appears to be driven by feature additions and bug fixes rather than a strict schedule, as indicated by recent updates like the enhanced `db.subtract` function.
npm install croxydbVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting various global configuration options for the database, performing core data operations like setting and retrieving values (including nested paths), manipulating arrays, checking for key existence, and deleting data. The example highlights asynchronous operations common with database interactions.
Pin the exact package version in your `package.json` (e.g., `"croxydb": "0.0.26"`) and review release notes carefully when updating to newer versions.
Review all usages of `db.subtract`. If negative values are undesired, implement explicit checks (e.g., `if (newValue < 0) newValue = 0;`) after subtraction or before persisting the value.
Always use `await` with `db` methods when operating with the MongoDB adapter. It is good practice to `await` all `db` operations to ensure consistency, even with local file adapters that might technically be synchronous.
Join the official Discord server for real-time support, to report bugs, and to stay updated. Implement robust error handling in your application to gracefully manage unexpected behaviors.
Ensure you are importing the default export: `import db from 'croxydb'` for ESM or `const db = require('croxydb')` for CommonJS. Avoid destructuring the import.Double-check the MongoDB connection URL for accuracy, including credentials. Verify the database user has the necessary permissions and that your server can establish a connection to the MongoDB host.
Ensure the directory specified by `db.setFolder()` exists or can be created by the application process. Verify file system permissions for the target directory to allow read and write access.