bst: batch op.

This commit is contained in:
Christopher Jeffrey 2016-06-22 04:35:56 -07:00
parent 135fca806c
commit 09e5d93a15
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -610,7 +610,7 @@ function Batch(tree, options) {
Batch.prototype.put = function(key, value) {
assert(this.tree, 'Already written.');
this.ops.push({ type: 'put', key: key, value: value });
this.ops.push(new BatchOp('put', key, value));
return this;
};
@ -621,7 +621,7 @@ Batch.prototype.put = function(key, value) {
Batch.prototype.del = function del(key) {
assert(this.tree, 'Already written.');
this.ops.push({ type: 'del', key: key });
this.ops.push(new BatchOp('del', key));
return this;
};
@ -666,6 +666,21 @@ Batch.prototype.clear = function clear() {
return this;
};
/**
* Batch Operation
* @constructor
* @private
* @param {String} type
* @param {Buffer} key
* @param {Buffer|null} value
*/
function BatchOp(type, key, value) {
this.type = type;
this.key = key;
this.value = value;
}
/**
* Iterator
* @constructor