level-remove-notfound

    0.0.2 • Public • Published

    level-remove-notfound

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

    build status

    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

    Keywords

    none

    Install

    npm i level-remove-notfound

    DownloadsWeekly Downloads

    1

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • alessioalex