Skip to content

Commit 9739bba

Browse files
committed
Document the return type of db.batch() and add example
1 parent 2d139c2 commit 9739bba

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![npm](https://img.shields.io/npm/v/abstract-level.svg)](https://www.npmjs.com/package/abstract-level)
99
[![Node version](https://img.shields.io/node/v/abstract-level.svg)](https://www.npmjs.com/package/abstract-level)
1010
[![Test](https://img.shields.io/github/workflow/status/Level/abstract-level/Test?label=test)](https://github.com/Level/abstract-level/actions/workflows/test.yml)
11-
[![Coverage](https://img.shields.io/codecov/c/github/Level/abstract-level?label=&logo=codecov&logoColor=fff)](https://codecov.io/gh/Level/abstract-level)
11+
[![Coverage](https://img.shields.io/codecov/c/github/Level/abstract-level?label=\&logo=codecov\&logoColor=fff)](https://codecov.io/gh/Level/abstract-level)
1212
[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript\&logoColor=fff)](https://standardjs.com)
1313
[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)
1414
[![Donate](https://img.shields.io/badge/donate-orange?logo=open-collective\&logoColor=fff)](https://opencollective.com/level)
@@ -30,7 +30,7 @@
3030
- [`db.put(key, value[, options][, callback])`](#dbputkey-value-options-callback)
3131
- [`db.del(key[, options][, callback])`](#dbdelkey-options-callback)
3232
- [`db.batch(operations[, options][, callback])`](#dbbatchoperations-options-callback)
33-
- [`db.batch()`](#dbbatch)
33+
- [`chainedBatch = db.batch()`](#chainedbatch--dbbatch)
3434
- [`iterator = db.iterator([options])`](#iterator--dbiteratoroptions)
3535
- [`keyIterator = db.keys([options])`](#keyiterator--dbkeysoptions)
3636
- [`valueIterator = db.values([options])`](#valueiterator--dbvaluesoptions)
@@ -56,6 +56,8 @@
5656
- [`iterator.seek(target[, options])`](#iteratorseektarget-options)
5757
- [`iterator.close([callback])`](#iteratorclosecallback)
5858
- [`iterator.db`](#iteratordb)
59+
- [`iterator.count`](#iteratorcount)
60+
- [`iterator.limit`](#iteratorlimit)
5961
- [`keyIterator`](#keyiterator)
6062
- [`valueIterator`](#valueiterator)
6163
- [`sublevel`](#sublevel)
@@ -335,9 +337,17 @@ await db.batch([
335337

336338
The `callback` function will be called with no arguments if the batch was successful or with an error if it failed. If no callback is provided, a promise is returned.
337339

338-
### `db.batch()`
340+
### `chainedBatch = db.batch()`
339341

340-
Create a [`chainedBatch`](#chainedbatch) object, when `batch()` is called with zero arguments. A chained batch can be used to build and eventually commit an atomic batch of operations. Depending on how it's used, it is possible to obtain greater performance with this form of `batch()`. On several implementations however, it is just sugar.
342+
Create a [chained batch](#chainedbatch), when `batch()` is called with zero arguments. A chained batch can be used to build and eventually commit an atomic batch of operations. Depending on how it's used, it is possible to obtain greater performance with this form of `batch()`. On several implementations however, it is just sugar.
343+
344+
```js
345+
await db.batch()
346+
.del('bob')
347+
.put('alice', 361)
348+
.put('kim', 220)
349+
.write()
350+
```
341351

342352
### `iterator = db.iterator([options])`
343353

0 commit comments

Comments
 (0)