@nxtedition/rocksdb 7.0.9 → 7.0.12

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 CHANGED
@@ -198,6 +198,8 @@ static napi_value ToError(napi_env env, const rocksdb::Status& status) {
198
198
  return CreateError(env, "LEVEL_NOT_FOUND", msg);
199
199
  } else if (status.IsCorruption()) {
200
200
  return CreateError(env, "LEVEL_CORRUPTION", msg);
201
+ } else if (status.IsTryAgain()) {
202
+ return CreateError(env, "LEVEL_TRYAGAIN", msg);
201
203
  } else if (status.IsIOError()) {
202
204
  if (msg.find("IO error: lock ") != std::string::npos) { // env_posix.cc
203
205
  return CreateError(env, "LEVEL_LOCKED", msg);
@@ -1393,6 +1395,21 @@ NAPI_METHOD(db_get_property) {
1393
1395
  return result;
1394
1396
  }
1395
1397
 
1398
+
1399
+ NAPI_METHOD(db_get_latest_sequence) {
1400
+ NAPI_ARGV(1);
1401
+
1402
+ Database* database;
1403
+ NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
1404
+
1405
+ const auto seq = database->db_->GetLatestSequenceNumber();
1406
+
1407
+ napi_value result;
1408
+ NAPI_STATUS_THROWS(napi_create_bigint_int64(env, seq, &result));
1409
+
1410
+ return result;
1411
+ }
1412
+
1396
1413
  NAPI_METHOD(iterator_init) {
1397
1414
  NAPI_ARGV(2);
1398
1415
 
@@ -1471,7 +1488,7 @@ NAPI_METHOD(iterator_get_sequence) {
1471
1488
  napi_value result;
1472
1489
  NAPI_STATUS_THROWS(napi_create_bigint_int64(env, seq, &result));
1473
1490
 
1474
- return 0;
1491
+ return result;
1475
1492
  }
1476
1493
 
1477
1494
  struct NextWorker final : public Worker {
@@ -1714,6 +1731,7 @@ NAPI_INIT() {
1714
1731
  NAPI_EXPORT_FUNCTION(db_del);
1715
1732
  NAPI_EXPORT_FUNCTION(db_clear);
1716
1733
  NAPI_EXPORT_FUNCTION(db_get_property);
1734
+ NAPI_EXPORT_FUNCTION(db_get_latest_sequence);
1717
1735
 
1718
1736
  NAPI_EXPORT_FUNCTION(iterator_init);
1719
1737
  NAPI_EXPORT_FUNCTION(iterator_seek);
package/index.js CHANGED
@@ -43,6 +43,10 @@ class RocksLevel extends AbstractLevel {
43
43
  this[kColumns] = {}
44
44
  }
45
45
 
46
+ get sequence () {
47
+ return binding.db_get_latest_sequence(this[kContext])
48
+ }
49
+
46
50
  get location () {
47
51
  return this[kLocation]
48
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.9",
3
+ "version": "7.0.12",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",