From 9fe25572e854870ca7beb5cafd306387b691d5d1 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2019 08:48:00 +0000 Subject: [PATCH 1/3] Upgrade abstract-leveldown from ~6.0.3 to ~6.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9038960c..61b69a4b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "prebuild-alpine": "IMAGE=alpine ./scripts/cross-compile --tag-libc" }, "dependencies": { - "abstract-leveldown": "~6.0.3", + "abstract-leveldown": "~6.1.1", "napi-macros": "~2.0.0", "node-gyp-build": "~4.1.0" }, From 07757d4a52dc242ee281dcb09f17f4514d495ffa Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 18 Aug 2019 11:26:18 +0200 Subject: [PATCH 2/3] Opt-in to new clear() tests --- test/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/common.js b/test/common.js index 14a4a904..de2612f2 100644 --- a/test/common.js +++ b/test/common.js @@ -7,5 +7,8 @@ module.exports = suite.common({ test: test, factory: function () { return leveldown(tempy.directory()) - } + }, + + // Opt-in to new clear() tests + clear: true }) From 984cf63378ec0563e2d1f94e49687e5165e35dcb Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 18 Aug 2019 11:31:42 +0200 Subject: [PATCH 3/3] Document new clear() method --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 5cafc75e..b014bd65 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ If you don't want to use the prebuilt binary for the platform you are installing - db.compactRange() - db.getProperty() - db.iterator() +- db.clear() - chainedBatch - chainedBatch.put() - chainedBatch.del() @@ -275,6 +276,19 @@ Returns a new [`iterator`](#iterator) instance. The optional `options` object ma - `valueAsBuffer` (boolean, default: `true`): Used to determine whether to return the `value` of each entry as a string or a Buffer. + + +### `db.clear([options, ]callback)` + +Delete all entries or a range. Not guaranteed to be atomic. Accepts the following range options (with the same rules as on iterators): + +- `gt` (greater than), `gte` (greater than or equal) define the lower bound of the range to be deleted. Only entries where the key is greater than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the entries deleted will be the same. +- `lt` (less than), `lte` (less than or equal) define the higher bound of the range to be deleted. Only entries where the key is less than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the entries deleted will be the same. +- `reverse` _(boolean, default: `false`)_: delete entries in reverse order. Only effective in combination with `limit`, to remove the last N records. +- `limit` _(number, default: `-1`)_: limit the number of entries to be deleted. This number represents a _maximum_ number of entries and may not be reached if you get to the end of the range first. A value of `-1` means there is no limit. When `reverse=true` the entries with the highest keys will be deleted instead of the lowest keys. + +If no options are provided, all entries will be deleted. The `callback` function will be called with no arguments if the operation was successful or with an `Error` if it failed for any reason. + ### `chainedBatch`