You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,7 @@ If you want to use [Promises](#promise-support), you will need a polyfill like [
77
77
For options specific to [`leveldown`][leveldown] and [`level-js`][level-js] ("underlying store" from here on out), please see their respective READMEs.
Note that `createIfMissing` is an option specific to [`leveldown`][leveldown].
141
144
145
+
<aname="supports"></a>
146
+
147
+
### `db.supports`
148
+
149
+
A read-only [manifest](https://github.com/Level/supports). Not [widely supported yet](https://github.com/Level/community/issues/83). Might be used like so:
150
+
151
+
```js
152
+
if (!db.supports.permanence) {
153
+
thrownewError('Persistent storage is required')
154
+
}
155
+
156
+
if (db.supports.bufferKeys&&db.supports.promises) {
Returns an [`abstract-leveldown` iterator](https://github.com/Level/abstract-leveldown/#iterator), which is what powers the readable streams above. Options are the same as the range options of <ahref="#createReadStream"><code>createReadStream</code></a> and are passed to the underlying store.
420
+
421
+
<aname="clear"></a>
422
+
423
+
### `db.clear([options][, callback])`
424
+
425
+
**This method is experimental. Not all underlying stores support it yet. Consult [Level/community#79](https://github.com/Level/community/issues/79) to find out if your (combination of) dependencies support `db.clear()`.**
426
+
427
+
Delete all entries or a range. Not guaranteed to be atomic. Accepts the following range options (with the same rules as on iterators):
428
+
429
+
-`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.
430
+
-`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.
431
+
-`reverse`_(boolean, default: `false`)_: delete entries in reverse order. Only effective in combination with `limit`, to remove the last N records.
432
+
-`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.
433
+
434
+
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 `WriteError` if it failed for any reason.
435
+
436
+
If no callback is passed, a promise is returned.
437
+
396
438
## Promise Support
397
439
398
440
`level(up)` ships with native `Promise` support out of the box.
@@ -404,6 +446,7 @@ Each function taking a callback also can be used as a promise, if the callback i
404
446
-`db.del(key[, options])`
405
447
-`db.batch(ops[, options])`
406
448
-`db.batch().write()`
449
+
-`db.clear(options)`
407
450
408
451
The only exception is the `level` constructor itself, which if no callback is passed will lazily open the underlying store in the background.
0 commit comments