diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..1ecf8960 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + threshold: 5% + patch: off diff --git a/README.md b/README.md index c693c094..48dca5e8 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ - [`db.close([callback])`](#dbclosecallback) - [`db.put(key, value[, options][, callback])`](#dbputkey-value-options-callback) - [`db.get(key[, options][, callback])`](#dbgetkey-options-callback) + - [`db.getMany(keys[, options][, callback])`](#dbgetmanykeys-options-callback) - [`db.del(key[, options][, callback])`](#dbdelkey-options-callback) - [`db.batch(array[, options][, callback])` _(array form)_](#dbbatcharray-options-callback-array-form) - [`db.batch()` _(chained form)_](#dbbatch-chained-form) @@ -208,7 +209,7 @@ If no callback is passed, a promise is returned. ### `db.get(key[, options][, callback])` -get() is the primary method for fetching data from the store. The `key` can be of any type. If it doesn't exist in the store then the callback or promise will receive an error. A not-found err object will be of type `'NotFoundError'` so you can `err.type == 'NotFoundError'` or you can perform a truthy test on the property `err.notFound`. +Get a value from the store by `key`. The `key` can be of any type. If it doesn't exist in the store then the callback or promise will receive an error. A not-found err object will be of type `'NotFoundError'` so you can `err.type == 'NotFoundError'` or you can perform a truthy test on the property `err.notFound`. ```js db.get('foo', function (err, value) { @@ -225,10 +226,20 @@ db.get('foo', function (err, value) { }) ``` -`options` is passed on to the underlying store. +The optional `options` object is passed on to the underlying store. If no callback is passed, a promise is returned. + + +### `db.getMany(keys[, options][, callback])` + +Get multiple values from the store by an array of `keys`. The optional `options` object is passed on to the underlying store. + +The `callback` function will be called with an `Error` if the operation failed for any reason. If successful the first argument will be `null` and the second argument will be an array of values with the same order as `keys`. If a key was not found, the relevant value will be `undefined`. + +If no callback is provided, a promise is returned. + ### `db.del(key[, options][, callback])` diff --git a/lib/levelup.js b/lib/levelup.js index 6dfbf67a..1e4e6acc 100644 --- a/lib/levelup.js +++ b/lib/levelup.js @@ -185,6 +185,10 @@ LevelUP.prototype.get = function (key, options, callback) { return callback.promise } +LevelUP.prototype.getMany = function (keys, options, callback) { + return this.db.getMany(keys, options, callback) +} + LevelUP.prototype.put = function (key, value, options, callback) { callback = getCallback(options, callback) callback = catering.fromCallback(callback) diff --git a/test/self.js b/test/self.js index 66cccf6b..e80e9a45 100644 --- a/test/self.js +++ b/test/self.js @@ -34,7 +34,6 @@ suite({ // TODO to make this pass: // - Have abstract-leveldown use level-errors // - Perform type checks in same order (e.g. check key before callback) -// - Add db.isClosed(), isOpen() to abstract-leveldown suite({ test: noop, factory: function (options) {