-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathchained-batch.js
More file actions
35 lines (26 loc) · 700 Bytes
/
chained-batch.js
File metadata and controls
35 lines (26 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict'
const { AbstractChainedBatch } = require('abstract-level')
const binding = require('./binding')
const kContext = Symbol('context')
class ChainedBatch extends AbstractChainedBatch {
constructor (db, context) {
super(db)
this[kContext] = binding.batch_init(context)
}
_put (key, value) {
binding.batch_put(this[kContext], key, value)
}
_del (key) {
binding.batch_del(this[kContext], key)
}
_clear () {
binding.batch_clear(this[kContext])
}
async _write (options) {
return binding.batch_write(this[kContext], options)
}
async _close () {
// TODO: close native batch (currently done on GC)
}
}
exports.ChainedBatch = ChainedBatch