gitmyhub

nedb

JavaScript ★ 14k updated 1y ago

The JavaScript Database, for Node.js, nw.js, electron and the browser

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.

JavaScriptNode.jssetup: easycomplexity 2/5

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.

Where it fits