@nxtedition/rocksdb 7.1.10 → 7.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.cc +19 -5
- package/index.js +2 -2
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
package/binding.cc
CHANGED
|
@@ -1495,23 +1495,37 @@ NAPI_METHOD(batch_write) {
|
|
|
1495
1495
|
napi_ref batchRef;
|
|
1496
1496
|
NAPI_STATUS_THROWS(napi_create_reference(env, argv[1], 1, &batchRef));
|
|
1497
1497
|
|
|
1498
|
-
|
|
1499
|
-
runAsync<State>(
|
|
1498
|
+
runAsync<int64_t>(
|
|
1500
1499
|
"leveldown.batch.write", env, callback,
|
|
1501
|
-
[=](
|
|
1500
|
+
[=](int64_t& seq) {
|
|
1502
1501
|
rocksdb::WriteOptions writeOptions;
|
|
1503
1502
|
writeOptions.sync = *sync;
|
|
1503
|
+
|
|
1504
|
+
// TODO (fix): Better way to get final batch sequence?
|
|
1505
|
+
seq = database->db->GetLatestSequenceNumber() + 1;
|
|
1506
|
+
|
|
1504
1507
|
return database->db->Write(writeOptions, batch);
|
|
1505
1508
|
},
|
|
1506
|
-
[=](
|
|
1509
|
+
[=](int64_t& seq, auto env, auto& argv) {
|
|
1510
|
+
argv.resize(2);
|
|
1511
|
+
NAPI_STATUS_RETURN(napi_delete_reference(env, batchRef));
|
|
1512
|
+
NAPI_STATUS_RETURN(napi_create_int64(env, seq, &argv[1]));
|
|
1513
|
+
return napi_ok;
|
|
1514
|
+
});
|
|
1507
1515
|
} else {
|
|
1516
|
+
// TODO (fix): Better way to get final batch sequence?
|
|
1517
|
+
auto seq = database->db->GetLatestSequenceNumber() + 1;
|
|
1518
|
+
|
|
1519
|
+
napi_value result;
|
|
1520
|
+
NAPI_STATUS_THROWS(napi_create_int64(env, seq, &result));
|
|
1521
|
+
|
|
1508
1522
|
rocksdb::WriteOptions writeOptions;
|
|
1509
1523
|
ROCKS_STATUS_THROWS_NAPI(database->db->Write(writeOptions, batch));
|
|
1510
1524
|
|
|
1511
1525
|
napi_value global;
|
|
1512
1526
|
NAPI_STATUS_THROWS(napi_get_global(env, &global));
|
|
1513
1527
|
|
|
1514
|
-
NAPI_STATUS_THROWS(napi_call_function(env, global, callback,
|
|
1528
|
+
NAPI_STATUS_THROWS(napi_call_function(env, global, callback, 1, &result, nullptr));
|
|
1515
1529
|
}
|
|
1516
1530
|
|
|
1517
1531
|
return 0;
|
package/index.js
CHANGED
|
@@ -206,14 +206,14 @@ class RocksLevel extends AbstractLevel {
|
|
|
206
206
|
const seq = this.sequence
|
|
207
207
|
let sync = true
|
|
208
208
|
this[kRef]()
|
|
209
|
-
binding.batch_write(this[kContext], context, options, (err) => {
|
|
209
|
+
binding.batch_write(this[kContext], context, options, (err, sequence) => {
|
|
210
210
|
this[kUnref]()
|
|
211
211
|
|
|
212
212
|
if (!err) {
|
|
213
213
|
this.emit('update', {
|
|
214
214
|
rows: batch.toArray(),
|
|
215
215
|
count: batch.length,
|
|
216
|
-
sequence: seq + 1
|
|
216
|
+
sequence: sequence ?? (seq + 1)
|
|
217
217
|
})
|
|
218
218
|
}
|
|
219
219
|
if (sync) {
|
package/package.json
CHANGED
|
Binary file
|