Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ If you don't want to use the prebuilt binary for the platform you are installing
- <a href="#leveldown_compactRange"><code>db.<b>compactRange()</b></code></a>
- <a href="#leveldown_getProperty"><code>db.<b>getProperty()</b></code></a>
- <a href="#leveldown_iterator"><code>db.<b>iterator()</b></code></a>
- <a href="#leveldown_clear"><code>db.<b>clear()</b></code></a>
- <a href="#chainedbatch"><code>chainedBatch</code></a>
- <a href="#chainedbatch_put"><code>chainedBatch.<b>put()</b></code></a>
- <a href="#chainedbatch_del"><code>chainedBatch.<b>del()</b></code></a>
Expand Down Expand Up @@ -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.

<a name="leveldown_clear"></a>

### `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.

<a name="chainedbatch"></a>

### `chainedBatch`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
5 changes: 4 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ module.exports = suite.common({
test: test,
factory: function () {
return leveldown(tempy.directory())
}
},

// Opt-in to new clear() tests
clear: true
})