Skip to content

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
Step-by-step guide: how to use NeDBInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install from npm

    npm install nedb --save

    Run tests (needs dev dependencies)

    npm test
  2. 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. 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

ProjectStarsTypeLevelUpdatedBest for
nedb (this)13.5kLibrarybeginner1.5 years agoSmall Node.js or Electron apps that need simple local storage without installing a separate database server
lowdb22.6kLibrarybeginner7 months agoNode.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.