explaingit

louischatriot/nedb

13,550JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

NeDB is a lightweight embedded JavaScript database with a MongoDB-like API that runs inside Node.js, Electron, or the browser with no separate server, note it is no longer actively maintained.

Mindmap

mindmap
  root((repo))
    What it does
      Embedded JS database
      No server needed
      MongoDB-style API
    Storage modes
      In-memory
      Persistent file
    Platforms
      Node.js
      Electron
      Browser
    Use cases
      Desktop app data
      Test datastores
      Simple persistence
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a persistent datastore to an Electron desktop app without installing or configuring a separate database server.

USE CASE 2

Store and query app data in Node.js scripts or browser apps using familiar MongoDB-style query operators.

USE CASE 3

Spin up a fast in-memory database during unit tests that resets automatically when the test suite finishes.

Tech stack

JavaScriptNode.js

Getting it running

Difficulty · easy Time to first run · 5min

No longer maintained and may contain unresolved bugs or security issues, consider an actively maintained fork for new projects.

In plain English

NeDB is a small database that runs directly inside a JavaScript application, with no installation of a separate database server required. It works in Node.js, Electron desktop apps, nw.js, and in the browser. You can use it as a temporary in-memory store that disappears when your app closes, or as a persistent store that saves data to a file on disk. The whole thing is pure JavaScript with no compiled dependencies, so it is easy to add to any project. The API follows the same patterns as MongoDB, a well-known database system, which means developers familiar with MongoDB can pick it up quickly. You can insert records, search for them using comparison operators like greater-than or less-than, filter by array contents, combine conditions with logical operators, sort and paginate results, update records in place, and delete records. You can also create indexes on fields to speed up searches. Data is stored using an append-only format, meaning updates and deletions add new entries to the file rather than overwriting old ones. The database compacts itself back to a clean one-record-per-line format each time you load it. If you need to encrypt data, the library provides hooks you can use to transform data before it is written to disk and after it is read back. One important note: the README prominently warns that this library is no longer maintained and may contain bugs and security issues. The maintainer asks that no new issues or pull requests be submitted. If you need something like NeDB for a new project, you would want to look for an actively maintained fork or alternative. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Using NeDB in Node.js, write code to create a persistent datastore, insert 10 records, and query for records where age is greater than 25.
Prompt 2
Show me how to use NeDB in an Electron app to save and retrieve user preferences without needing a database server.
Prompt 3
Write NeDB code that creates an index on the email field, inserts several user records, and finds a user by email.
Prompt 4
How do I use NeDB's data transformation hooks to encrypt records before they are written to disk and decrypt them on read?
Open on GitHub → Explain another repo

← louischatriot on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.