File System DB (FSDB) is a lightweight, synchronous, file-based JSON database designed for Node.js environments, currently at version 2.1.0. It allows developers to store and retrieve data using a key-value paradigm, supporting dot notation for nested JSON fields. A key differentiator is its simplicity and lack of external dependencies, relying solely on Node.js's built-in File System module. Data is stored directly as human-readable JSON files, making it easy to inspect and manage backups. While highly accessible, its synchronous nature means operations can potentially block the event loop for very large datasets, and its reliance on persistent file storage makes it unsuitable for ephemeral hosting environments like Heroku or Vercel. The library ships with TypeScript types, enhancing developer experience for type-safe applications. New minor versions appear to be released on an as-needed basis.
npm install file-system-dbVerified import paths — ran on the pinned version, not inferred.
Initializes a file-system database, sets and retrieves key-value data with dot notation, updates, deletes, and creates a backup, then cleans up.
Refer to the v2 migration guide at https://github.com/WillTDA/File-System-DB/pull/6 to understand the necessary code adjustments.
Use a cloud-based database service (e.g., MongoDB Atlas, PostgreSQL, Firebase) for applications deployed on ephemeral platforms. File System DB is best suited for local development, desktop applications, or dedicated servers with persistent storage.
For applications requiring high concurrency, large data volumes, or non-blocking I/O, consider an asynchronous database solution. Minimize the frequency of write operations or offload heavy database tasks to worker threads if using FSDB in a performance-critical application.
Regularly use the `db.backup()` function to create recovery points. Implement robust error handling around database operations. Avoid direct manual editing of the database JSON file while the application is running.
Ensure the directory where the database file or backup file is intended to be created already exists. Use `path.join()` for cross-platform paths and consider `fs.mkdirSync(path.dirname(dbPath), { recursive: true });` if directories need to be created dynamically.Inspect the database JSON file at the specified path for syntax errors. If a backup is available, restore from the last valid backup. Avoid manual editing of the live database file.
Ensure you are correctly initializing the database with `const db = new FSDB();` or `const db = new FSDB('./my-db.json');`. Verify your `import` or `require` statement matches the package's export structure (e.g., `const { FSDB } = require('file-system-db');`).No dependency data recorded yet.