level-remove-notfound

levelUp.get won't callback with notFoundError anymore, instead (null, null)

npm install level-remove-notfound
2 downloads in the last week
8 downloads in the last month

level-remove-notfound

In case you don't want level.get(key) to return an error in case key doesn't exist.

[![build status] (https://secure.travis-ci.org/alessioalex/level-remove-notfound.png)] (http://travis-ci.org/alessioalex/level-remove-notfound)

Example

var level  = require('level'),
    assert = require('assert'),
    get    = require('level-remove-notfound'),
    db;

db = get.install(level('/tmp/' + Date.now() + '.db'));

db.get('foo', function(err, val) {
  assert.equal(err, null, 'error should be null');
  assert.equal(val, null, 'val should be null');

  db.put('foo', 'bar', function(err) {
    if (err) { throw err; }

    db.get('foo', function(err, val) {
      assert.equal(err, null, 'error should be null');
      assert.equal(val, 'bar', 'val === "bar"');
    });
  });
});

API

get(db, key, [levelUpOptions], cb)

Get a value in db without receiving notFoundError in case that value doesn't exist.

get.install(db)

db#get(key, [levelUpOptions], cb)

Install level-remove-notfound onto the db.

Installation

With npm do:

npm install level-remove-notfound

License

MIT

npm loves you