A very basic leveldb wrapper for storing objects that belong to 'documents'.


This is a module that provides functions for using a LevelDb database (via levelup) to store JSON objects in a really basic way.

It's geared toward a two-level hierarchy: There's documents, which are a collection of objects. And then there's objects. You don't have to use the documents. Since you can store anything you want in an object, you can create all sorts of hierarchies. However, since objects are stored with keys that use the document id, getting all the objects in a document is optimized. (See getDocObjectStream.)

It expect objects to have an 'id' string property as well as a 'doc' string property. If you don't want to bother with documents, just use the same string for every doc property.

var levelwrap = require('basicset-levelwrap').createLevelWrap('stuff.db');
    id: uid(8),
    name: 'Red Shyguy',
    doc: docAId,
    hp: 1,
    shouldTurnAwayFromCliffs: false
  function done(error, obj) {
    if (error) {
    else {
      console.log('OK, cool.');
mocha --ui tdd -R spec tests/levelwraptests.js