Lightweight Javascript DB for use in Node.js

JavascriptDatabaseKey Value-Store

Javascript Problem Overview


Anybody know of a lightweight yet durable database, written in Javascript, that can be used with Node.js.

I don't want the 'weight' of (great) solutions like Mongo or Couch. A simple, in memory JS database with the capability to persist to disk as a file would be enough. I would only use it to store small amounts of data.

Requirements:

  • can run in process with a node.js server application
  • can save the whole database to disk and recover after a failure
  • NO need for atomic writes or transaction supports
  • fast queries and sorting would be nice
  • only needs to support small data volumes, up to 1MB in total

I've come across TAFFY db so far but it really doesn't seem optimized for use in Node.js. Anybody seen what I'm looking for out there?

Thanks

Javascript Solutions


Solution 1 - Javascript

I had the same requirements as you but couldn't find a suitable database. nStore was promising but the API was not nearly complete enough and not very coherent.

That's why I made NeDB, which a dependency-less embedded database for Node.js projects. You can use it with a simple require(), it is persistent, and its API is the most commonly used subset of the very well-known MongoDB API.

https://github.com/louischatriot/nedb

Solution 2 - Javascript

Lokijs: A fast, in-memory document-oriented datastore for node.js, browser and cordova.

  • In-memory Javascript Datastore wih Persistence
  • In-Browser NoSQL db with syncing and persisting
  • a Redis-style store an npm install away
  • Persistable NoSQL db for Cordova
  • Embeddable NoSQL db with Persistence for node-webkit

LokiJS to be the ideal solution:

  • Mobile applications - especially HTML5 based (Cordova, Phonegap, etc.)
  • Node.js embedded datastore for small-to-medium apps
  • Embedded in desktop application with Node Webkit

https://github.com/techfort/LokiJS

Solution 3 - Javascript

NeDB seems to be what you are looking for. From the blurb:

> Embedded persistent database for Node.js, written in Javascript, with no dependency (except npm modules of course). You can think of it as a SQLite for Node.js projects, which can be used with a simple require statement. The API is a subset of MongoDB's. You can use it as a persistent or an in-memory only datastore.

Solution 4 - Javascript

Take a look at http://www.tingodb.com. I believe it does what you looking for. Additionally it fully compatible with MongoDB API. This reduces implementation risks and gives you option to switch to heavy solution as your app grows.

https://github.com/sergeyksv/tingodb

Solution 5 - Javascript

I'm only familiar with Mongo and Couch, but there's also one named Persistence.

Solution 6 - Javascript

Try nStore, it seems like a nice key/value lightweight dembedded db for node. See https://github.com/creationix/nstore

Solution 7 - Javascript

I had trouble with SQLite3, nStore and Alfred.

What works for me is node-dirty:

path = "#{__dirname}/data/messages.json"
messages = db path

message = 'text': 'Lorem ipsum dolor sit...'

messages.on "load", ->    
    messages.set 'my-unique-key', message, ->
        console.log messages.get('my-unique-key').text

    messages.forEach (key, value) ->
        console.log "Found key: #{key}, val: %j", value

messages.on "drain", ->
    console.log "Saved to #{path}"

Solution 8 - Javascript

LevelUP aims to expose the features of LevelDB in a Node.js-friendly way.

https://github.com/rvagg/node-levelup

You can also look at UnQLite. with a node.js binding node-unqlite

https://github.com/symisc/unqlite

Solution 9 - Javascript

Maybe you should try LocallyDB it's easy-to-use and lightweight in addition to the with advanced selecting system similar to javascript conditional expression...

https://github.com/btwael/locallydb

Solution 10 - Javascript

UeberDB provides abstraction for various databases

https://github.com/pita/ueberDB

https://www.npmjs.org/package/ueberDB

Solution 11 - Javascript

I wrote jaguarDb to handle some of the things that you are mentioning since I sometimes need a "little" database for demo or test projects too and I don't want to depend on mongoDB or another real database.

https://github.com/hectorcorrea/jaguarDb

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionConfusedNoobView Question on Stackoverflow
Solution 1 - JavascriptLouis ChatriotView Answer on Stackoverflow
Solution 2 - JavascriptDamodaranView Answer on Stackoverflow
Solution 3 - JavascriptChristof JansView Answer on Stackoverflow
Solution 4 - JavascriptSergey KorotkovView Answer on Stackoverflow
Solution 5 - JavascriptSteveView Answer on Stackoverflow
Solution 6 - JavascriptGuy KorlandView Answer on Stackoverflow
Solution 7 - JavascriptRadekView Answer on Stackoverflow
Solution 8 - Javascriptuser2870483View Answer on Stackoverflow
Solution 9 - JavascriptWael BoutglayView Answer on Stackoverflow
Solution 10 - JavascriptJohn McLearView Answer on Stackoverflow
Solution 11 - JavascriptHector CorreaView Answer on Stackoverflow