Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: mp/new_api
Fetching contributors…

Cannot retrieve contributors at this time

97 lines (71 sloc) 2.347 kb

Build Status


The leveldb library provides a persistent key value store. Keys and values are arbitrary byte arrays. The keys are ordered within the key value store according to a user-specified comparator function.

This project is node bindings to this excellent library so that node programs can either implement their own custom databases or simply use it directly as a fast, simple key/value store.

While implementing nStore, I realized there are a couple things that V8 and node are not very good at. They are heavy disk I/O and massive objects with either millions of keys or millions of sub objects.

Since LevelDB provides good primitives like MVCC and binary support (It was designed to back IndexDB in the Chrome browser), then it can be used as a base to implement things like CouchDB.


var leveldb = require('leveldb');"path/to/my/db", { create_if_missing: true }, onOpen);

function onOpen(err, db) {
  var key = "mykey";
  db.put(key, "My Value!", function(err) {
    db.getSync(key, function(err, value) {
      console.dir(value); // prints: My Value!

// db closes automatically when out of scope


npm install leveldb


So far, compiles on Ubuntu and Mac OS X Lion.

node-waf configure build

The leveldb library is bundled in the deps folder and is compiled in staticly. The resulting node addon is about 4mb unstripped. If you want to make it smaller, I've had success using the strip command on it which shrinks it down to about 300kb.

strip build/leveldb.node

Running tests

Tests are written using the mocha test framework. The test command automatically builds the required files prior to running the tests.

npm test


   161  Michael Phan-Ba
    39  Tim Caswell
    22  Nathan Landis
    12  Stefan Thomas
     9  Carter Thaxton
     9  Randall Leeds
     6  Damon Oehlman
     5  Hans Wennborg
     4  shinuza
     2  Sanjay Ghemawat
     1  (no author)
     1  Gabor Cselle
Jump to Line
Something went wrong with that request. Please try again.