
NeDB
A small embedded JavaScript database for Node.js, Electron and browsers, with no native dependencies.
- Stars
- 13.5k
- Forks
- 1k
- Licence
- MIT
- Language
- JavaScript
- Last update
- 1.5 years ago
- Type
- Library
No commits in over a year — check for forks or alternatives before adopting.
What it is
NeDB is a database library written entirely in JavaScript that you add to a Node.js, nw.js, Electron or browser project. It can run purely in memory or save data to a file on disk, and its query API is described as a subset of MongoDB's. The README says the maintainer no longer maintains it, so it is mainly useful for small projects or for studying an existing codebase.
- Store user settings or app state in a local file in an Electron app
- Keep an in-memory collection of documents during tests with no file written
- Use separate datastores as separate collections, each backed by its own file
- Run queries with operators such as $lt, $in and $or against stored documents
Great for
- Small Node.js or Electron apps that need simple local storage without installing a separate database server
- Prototypes and tests that want an in-memory datastore
- Developers already familiar with MongoDB-style queries who want a lightweight local store
- Projects that must avoid binary dependencies
Not ideal for
- Production systems that need active maintenance or security fixes, because the README says the library is no longer maintained and security alerts will not be answered
- Large datasets or heavy concurrent workloads, since the README stresses small embedded use and notes compaction blocks other operations
How to get it
- 1
Install with a package manager
You'll need: Node.js
Install from npm
npm install nedb --saveRun tests (needs dev dependencies)
npm test - 2
Run it
- Install the package with npm install nedb --save
- Create a datastore with var Datastore = require('nedb') and new Datastore() for in-memory use
- Or pass a filename option for a persistent datastore and call loadDatabase, or set autoload: true
- Issue insert, find, update or remove commands against the datastore
- 3
Get the most out of it
- Use the timestampData option to automatically track createdAt and updatedAt fields
- Set corruptAlertThreshold to control how much file corruption NeDB tolerates before refusing to start
- Use afterSerialization and beforeDeserialization hooks together to encrypt data on disk, keeping them strict inverses as the README warns
- Pass a compareStrings function when sorting accented or non-US characters
- Use setAutocompactionInterval if you want periodic compaction (minimum 5s interval)
Downloads
Strengths
- Written entirely in JavaScript with no binary dependency, per the README
- API is described as a subset of MongoDB's most-used operations
- Supports both in-memory and file-backed persistent datastores
Trade-offs
- The README warns the project is no longer maintained and may have bugs and security issues
- Persistence uses an append-only file that is compacted on load, and compaction blocks other operations
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| nedb (this) | 13.5k | Library | beginner | 1.5 years ago | Small Node.js or Electron apps that need simple local storage without installing a separate database server |
| lowdb | 22.6k | Library | beginner | 7 months ago | Node.js developers building small tools or prototypes that need simple persistent storage |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.