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
{{ message }}
This repository was archived by the owner on Dec 1, 2024. It is now read-only.
@@ -152,18 +161,24 @@ The only property currently available on the `options` object is `sync` *(boolea
152
161
The `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
153
162
154
163
<aname="leveldown_batch"></a>
155
-
### `db.batch(operations[, options], callback)`
156
-
<code>batch()</code> is an instance method on an existing database object. Used for very fast bulk-write operations (both *put* and *delete*). The `operations` argument should be an `Array` containing a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside LevelDB.
Each operation is contained in an object having the following properties: `type`, `key`, `value`, where the *type* is either `'put'` or `'del'`. In the case of `'del'` the `'value'` property is ignored. Any entries with a `'key'` of `null` or `undefined` will cause an error to be returned on the `callback`. Any entries where the *type* is `'put'` that have a `'value'` of `undefined`, `null`, `[]`, `''` or `Buffer.alloc(0)` will be stored as a zero-length character array and therefore be fetched during reads as either `''` or `Buffer.alloc(0)` depending on how they are requested.
166
+
Perform multiple _put_ and/or _del_ operations in bulk. The `operations` argument must be an `Array` containing a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation.
159
167
160
-
See [`levelup`](https://github.com/level/levelup#batch) for full documentation on how this works in practice.
168
+
Each operation is contained in an object having the following properties: `type`, `key`, `value`, where the `type` is either `'put'` or `'del'`. In the case of `'del'` the `value` property is ignored.
161
169
162
-
#### `options`
170
+
Any entries where the `key` or `value` (in the case of `'put'`) is `null` or `undefined` will cause an error to be returned on the `callback`. Any entries where the `type` is `'put'` that have a `value` of `[]`, `''` or `Buffer.alloc(0)` will be stored as a zero-length character array and therefore be fetched during reads as either `''` or `Buffer.alloc(0)` depending on how they are requested. See [`levelup`](https://github.com/level/levelup#batch) for full documentation on how this works in practice.
163
171
164
-
The only property currently available on the `options`object is `sync`*(boolean, default: `false`)*. See <ahref="#leveldown_put">leveldown#put()</a> for details about this option.
172
+
The optional `options`argument may contain:
165
173
166
-
The `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
174
+
-`sync`*(boolean, default: `false`)*. See [`db.put()`](#leveldown_put) for details about this option.
175
+
176
+
The `callback` function will be called with no arguments if the batch is successful or with an `Error` if the batch failed for any reason.
177
+
178
+
<aname="leveldown_chainedbatch"></a>
179
+
### `db.batch()`_(chained form)_
180
+
181
+
Returns a new [`chainedBatch`](#chainedbatch) instance.
167
182
168
183
<aname="leveldown_approximateSize"></a>
169
184
### `db.approximateSize(start, end, callback)`
@@ -194,12 +209,9 @@ Currently, the only valid properties are:
194
209
* <b><code>'leveldb.sstables'</code></b>: returns a multi-line string describing all of the *sstables* that make up contents of the current database.
195
210
196
211
<aname="leveldown_iterator"></a>
197
-
### `iterator = db.iterator([options])`
198
-
<code>iterator()</code> is an instance method on an existing database object. It returns a new **Iterator** instance.
212
+
### `db.iterator([options])`
199
213
200
-
#### `options`
201
-
202
-
The optional `options` object may contain:
214
+
Returns a new [`iterator`](#iterator) instance. The optional `options` object may contain:
203
215
204
216
*`gt` (greater than), `gte` (greater than or equal) define the lower bound of the values to be fetched and will determine the starting point where `reverse` is *not*`true`. Only records where the key is greater than (or equal to) this option will be included in the range. When `reverse` is `true` the order will be reversed, but the records returned will be the same.
205
217
@@ -221,8 +233,44 @@ The optional `options` object may contain:
221
233
222
234
*`valueAsBuffer`*(boolean, default: `true`)*: Used to determine whether to return the `value` of each entry as a string or a Buffer.
223
235
236
+
<aname="chainedbatch"></a>
237
+
### `chainedBatch`
238
+
239
+
<aname="chainedbatch_put"></a>
240
+
#### `chainedBatch.put(key, value)`
241
+
242
+
Queue a `put` operation on this batch. This may throw if `key` or `value` is invalid, following the same rules as the [array form of `db.batch()`](#leveldown_batch).
243
+
244
+
<aname="chainedbatch_del"></a>
245
+
#### `chainedBatch.del(key)`
246
+
247
+
Queue a `del` operation on this batch. This may throw if `key` is invalid.
248
+
249
+
<aname="chainedbatch_clear"></a>
250
+
#### `chainedBatch.clear()`
251
+
252
+
Clear all queued operations on this batch.
253
+
254
+
<aname="chainedbatch_write"></a>
255
+
#### `chainedBatch.write([options, ]callback)`
256
+
257
+
Commit the queued operations for this batch. All operations will be written atomically, that is, they will either all succeed or fail with no partial commits.
258
+
259
+
The optional `options` argument may contain:
260
+
261
+
-`sync`*(boolean, default: `false`)*. See [`db.put()`](#leveldown_put) for details about this option.
262
+
263
+
The `callback` function will be called with no arguments if the batch is successful or with an `Error` if the batch failed for any reason. After `write` has been called, no further operations are allowed.
264
+
265
+
<aname="chainedbatch_db"></a>
266
+
#### `chainedBatch.db`
267
+
268
+
A reference to the `db` that created this chained batch.
269
+
270
+
### `iterator`
271
+
224
272
<aname="iterator_next"></a>
225
-
### `iterator.next(callback)`
273
+
####`iterator.next(callback)`
226
274
<code>next()</code> is an instance method on an existing iterator object, used to increment the underlying LevelDB iterator and return the entry at that location.
227
275
228
276
the `callback` function will be called with no arguments in any of the following situations:
@@ -239,15 +287,20 @@ Otherwise, the `callback` function will be called with the following 3 arguments
239
287
*`value` - either a string or a Buffer depending on the `valueAsBuffer` argument when the `iterator()` was called.
240
288
241
289
<aname="iterator_seek"></a>
242
-
### `iterator.seek(key)`
290
+
####`iterator.seek(key)`
243
291
<code>seek()</code> is an instance method on an existing iterator object, used to seek the underlying LevelDB iterator to a given key.
244
292
245
293
By calling <code>seek(key)</code>, subsequent calls to <code>next(cb)</code> will return key/values larger or smaller than `key`, based on your <code>reverse</code> setting in the iterator constructor.
246
294
247
295
<aname="iterator_end"></a>
248
-
### `iterator.end(callback)`
296
+
####`iterator.end(callback)`
249
297
<code>end()</code> is an instance method on an existing iterator object. The underlying LevelDB iterator will be deleted and the `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
250
298
299
+
<aname="iterator_db"></a>
300
+
#### `iterator.db`
301
+
302
+
A reference to the `db` that created this iterator.
303
+
251
304
<aname="leveldown_destroy"></a>
252
305
### `leveldown.destroy(location, callback)`
253
306
<code>destroy()</code> is used to completely remove an existing LevelDB database directory. You can use this function in place of a full directory *rm* if you want to be sure to only remove LevelDB-related files. If the directory only contains LevelDB files, the directory itself will be removed as well. If there are additional, non-LevelDB files in the directory, those files, and the directory, will be left alone.
0 commit comments