Skip to content

Commit a909ea6

Browse files
committed
Document the return type of db.batch() and add example
1 parent 1ba0b69 commit a909ea6

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- [`db.put(key, value[, options][, callback])`](#dbputkey-value-options-callback)
3232
- [`db.del(key[, options][, callback])`](#dbdelkey-options-callback)
3333
- [`db.batch(operations[, options][, callback])`](#dbbatchoperations-options-callback)
34-
- [`db.batch()`](#dbbatch)
34+
- [`chainedBatch = db.batch()`](#chainedbatch--dbbatch)
3535
- [`iterator = db.iterator([options])`](#iterator--dbiteratoroptions)
3636
- [About high water](#about-high-water)
3737
- [`keyIterator = db.keys([options])`](#keyiterator--dbkeysoptions)
@@ -57,7 +57,6 @@
5757
- [`iterator.seek(target[, options])`](#iteratorseektarget-options)
5858
- [`iterator.close([callback])`](#iteratorclosecallback)
5959
- [`iterator.db`](#iteratordb)
60-
- [`iterator.db`](#iteratordb-1)
6160
- [`iterator.count`](#iteratorcount)
6261
- [`iterator.limit`](#iteratorlimit)
6362
- [`keyIterator`](#keyiterator)
@@ -349,9 +348,17 @@ await db.batch([
349348

350349
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.
351350

352-
### `db.batch()`
351+
### `chainedBatch = db.batch()`
353352

354-
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()`.
353+
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()`.
354+
355+
```js
356+
await db.batch()
357+
.del('bob')
358+
.put('alice', 361)
359+
.put('kim', 220)
360+
.write()
361+
```
355362

356363
### `iterator = db.iterator([options])`
357364

0 commit comments

Comments
 (0)