level-namespace

namespaces for levelup

npm install level-namespace
4 downloads in the last week
16 downloads in the last month

level-namespacebuild status

namespaces for levelup

Usage/demo


var namespace = require('level-namespace');
namespace(db);

var namespace = db.namespace('example');

// most of the levelup-methods are supported
namespace.put('foo', 'bar', function(err) {
    if (err) throw err;

    namespace.get('foo', function(err, value) {
        assert.equal(value, 'bar');
    });

    db.get('example:foo', function(err, value) {
        assert.equal(value, 'bar');
    });
});

db.batch([
        { type: 'put', key: 'foo', value: 'baz' },
        { type: 'put', key: 'example:foo', value: 'bar' },
        { type: 'put', key: 'example:hello', value: 'world' },
        { type: 'put', key: 'example;hello', value: 'worldz' }
    ], function() {
        // will print
        // 'bar' and then 'world' to process.stdout
        namespace.valueStream().pipe(process.stdout)
        // namespace also support valueStream, readStream & writeStream also
    }
)

Licence

MIT

npm loves you