@nxtedition/rocksdb 7.0.30 → 7.0.31

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
@@ -856,11 +856,11 @@ NAPI_METHOD(db_open) {
856
856
  NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "maxBackgroundJobs", maxBackgroundJobs));
857
857
 
858
858
  napi_value walTTL;
859
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_ttl_seconds, &walTTL));
859
+ NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_ttl_seconds * 1e3, &walTTL));
860
860
  NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "walTTL", walTTL));
861
861
 
862
862
  napi_value walSizeLimit;
863
- NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_size_limit_MB, &walSizeLimit));
863
+ NAPI_STATUS_THROWS(napi_create_int64(env, dbOptions.WAL_size_limit_MB * 1e6, &walSizeLimit));
864
864
  NAPI_STATUS_THROWS(napi_set_named_property(env, ret, "walSizeLimit", walSizeLimit));
865
865
 
866
866
  napi_value walCompression;
@@ -1149,15 +1149,30 @@ NAPI_METHOD(updates_init) {
1149
1149
  Database* database;
1150
1150
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
1151
1151
 
1152
- const auto seqNumber = Int64Property(env, argv[1], "since").value_or(database->db_->GetLatestSequenceNumber());
1153
- const auto keys = BooleanProperty(env, argv[1], "keys").value_or(true);
1154
- const auto values = BooleanProperty(env, argv[1], "values").value_or(true);
1155
- const auto data = BooleanProperty(env, argv[1], "data").value_or(true);
1152
+ napi_value sinceProperty;
1153
+ int64_t since;
1154
+ NAPI_STATUS_THROWS(napi_get_named_property(env, argv[1], "since", &sinceProperty));
1155
+ NAPI_STATUS_THROWS(napi_get_value_int64(env, sinceProperty, &since));
1156
+
1157
+ napi_value keysProperty;
1158
+ bool keys;
1159
+ NAPI_STATUS_THROWS(napi_get_named_property(env, argv[1], "keys", &keysProperty));
1160
+ NAPI_STATUS_THROWS(napi_get_value_bool(env, keysProperty, &keys));
1161
+
1162
+ napi_value valuesProperty;
1163
+ bool values;
1164
+ NAPI_STATUS_THROWS(napi_get_named_property(env, argv[1], "values", &valuesProperty));
1165
+ NAPI_STATUS_THROWS(napi_get_value_bool(env, valuesProperty, &values));
1166
+
1167
+ napi_value dataProperty;
1168
+ bool data;
1169
+ NAPI_STATUS_THROWS(napi_get_named_property(env, argv[1], "data", &dataProperty));
1170
+ NAPI_STATUS_THROWS(napi_get_value_bool(env, dataProperty, &data));
1156
1171
 
1157
1172
  rocksdb::ColumnFamilyHandle* column;
1158
1173
  NAPI_STATUS_THROWS(GetColumnFamily(database, env, argv[1], &column, false));
1159
1174
 
1160
- auto updates = std::make_unique<Updates>(database, seqNumber, keys, values, data, column);
1175
+ auto updates = std::make_unique<Updates>(database, since, keys, values, data, column);
1161
1176
 
1162
1177
  napi_value result;
1163
1178
  NAPI_STATUS_THROWS(napi_create_external(env, updates.get(), Finalize<Updates>, updates.get(), &result));
package/index.js CHANGED
@@ -151,14 +151,32 @@ class RocksLevel extends AbstractLevel {
151
151
  }
152
152
 
153
153
  async getCurrentWALFile () {
154
+ if (this.status !== 'open') {
155
+ throw new ModuleError('Database is not open', {
156
+ code: 'LEVEL_DATABASE_NOT_OPEN'
157
+ })
158
+ }
159
+
154
160
  return binding.db_get_current_wal_file(this[kContext])
155
161
  }
156
162
 
157
163
  async getSortedWALFiles () {
164
+ if (this.status !== 'open') {
165
+ throw new ModuleError('Database is not open', {
166
+ code: 'LEVEL_DATABASE_NOT_OPEN'
167
+ })
168
+ }
169
+
158
170
  return binding.db_get_sorted_wal_files(this[kContext])
159
171
  }
160
172
 
161
173
  async flushWAL (options) {
174
+ if (this.status !== 'open') {
175
+ throw new ModuleError('Database is not open', {
176
+ code: 'LEVEL_DATABASE_NOT_OPEN'
177
+ })
178
+ }
179
+
162
180
  binding.db_flush_wal(this[kContext], options)
163
181
  }
164
182
 
@@ -208,6 +226,29 @@ class RocksLevel extends AbstractLevel {
208
226
  })
209
227
  }
210
228
 
229
+ options = {
230
+ since: options?.since ?? 0,
231
+ keys: options?.keys ?? true,
232
+ values: options?.values ?? true,
233
+ data: options?.data ?? true
234
+ }
235
+
236
+ if (typeof options.since !== 'number') {
237
+ throw new TypeError("'since' must be nully or a number")
238
+ }
239
+
240
+ if (typeof options.keys !== 'boolean') {
241
+ throw new TypeError("'keys' must be nully or a boolean")
242
+ }
243
+
244
+ if (typeof options.values !== 'boolean') {
245
+ throw new TypeError("'values' must be nully or a boolean")
246
+ }
247
+
248
+ if (typeof options.data !== 'boolean') {
249
+ throw new TypeError("'data' must be nully or a boolean")
250
+ }
251
+
211
252
  class Updates {
212
253
  constructor (db, options) {
213
254
  this.context = binding.updates_init(db[kContext], options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "7.0.30",
3
+ "version": "7.0.31",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",