Skip to content

Commit

Permalink
Add db.getMany(keys) (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Sep 28, 2021
1 parent 9c6f40f commit 9d9691a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion memdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ function MemDOWN () {
snapshots: true,
permanence: false,
seek: true,
clear: true
clear: true,
getMany: true
})

this._store = createRBT(ltgt.compare)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"CONTRIBUTORS.md"
],
"dependencies": {
"abstract-leveldown": "^7.0.0",
"abstract-leveldown": "^7.2.0",
"buffer": "^6.0.3",
"functional-red-black-tree": "^1.0.1",
"inherits": "^2.0.1",
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9d9691a

Please sign in to comment.