From 3ccfe1629d5bd2799a465500f1c08c9782fd01d5 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 25 Sep 2021 14:40:20 +0200 Subject: [PATCH] Add `db.getMany(keys)` Ref https://github.com/Level/community/issues/101 --- memdown.js | 10 +++++++++- test.js | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/memdown.js b/memdown.js index 9233a4f..c5c1de9 100644 --- a/memdown.js +++ b/memdown.js @@ -158,7 +158,8 @@ function MemDOWN () { snapshots: true, permanence: false, seek: true, - clear: true + clear: true, + getMany: true }) this._store = createRBT(ltgt.compare) @@ -211,6 +212,13 @@ MemDOWN.prototype._get = function (key, options, callback) { }) } +MemDOWN.prototype._getMany = function (keys, options, callback) { + this._nextTick(callback, null, keys.map((key) => { + const value = this._store.get(key) + return value === undefined || options.asBuffer ? value : value.toString() + })) +} + MemDOWN.prototype._del = function (key, options, callback) { this._store = this._store.remove(key) this._nextTick(callback) diff --git a/test.js b/test.js index 639ec96..e60e914 100644 --- a/test.js +++ b/test.js @@ -14,8 +14,9 @@ const testCommon = suite.common({ return memdown() }, - // Opt-in to new clear() tests + // Opt-in to new tests clear: true, + getMany: true, // Opt-out of unsupported features createIfMissing: false,