csv-database is a lightweight Node.js library offering a complete CRUD (Create, Read, Update, Delete) API, utilizing CSV files for data storage. Built with TypeScript and leveraging async/await, it provides native JavaScript object interaction, allowing developers to query and manipulate data using familiar object predicates. As of version 0.9.2, it is in active development, with a focus on stability for its upcoming 1.0 release. Key differentiators include its strong TypeScript typings, built-in model validation, and a focus on being "concurrency-ready" for file operations. It's designed for applications requiring simple, local data persistence without the overhead of a full relational or NoSQL database, making it suitable for smaller projects or configuration storage.
npm install csv-databaseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a CSV database, add, retrieve, edit, and delete records, and clean up the created file.
Initialize the database with the desired delimiter: `const db = await csvdb("users.csv", ["id","name","mail"], ",");`Ensure all keys in your predicate objects exactly match one of the fields defined in your database model. For example, if your model is `['id', 'name']`, a predicate `{ userID: 1 }` will fail.Monitor the project's GitHub repository or release notes for upcoming changes, especially when upgrading between minor versions. Consider pinning to a specific minor version for production deployments (`~0.9.2` instead of `^0.9.2`).
Review your database model definition and ensure all predicate keys exactly match a field in the model. E.g., if model is `['id', 'name']`, use `{ id: 1 }` not `{ userID: 1 }`.Ensure you `await` the `csvdb` call (e.g., `const db = await csvdb(...)`). If using CommonJS, use `const csvdb = require('csv-database').default;`.Check the permissions of the directory where the CSV file is located. Ensure the user running the Node.js application has read/write/delete access to that directory.
No dependency data recorded yet.