Remove the check for notFoundError when using levelUp.get()
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

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