@harperfast/rocksdb-js 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -927,6 +927,8 @@ The default `Store` contains the following methods which can be overridden:
927
927
  - `encodeValue(value)`
928
928
  - `get(context, key, resolve, reject, txnId?)`
929
929
  - `getCount(context, options?, txnId?)`
930
+ - `getKeys(context, options?)`
931
+ - `getKeysCount(context, options?)`
930
932
  - `getRange(context, options?)`
931
933
  - `getSync(context, key, options?)`
932
934
  - `getUserSharedBuffer(key, defaultBuffer?)`
package/dist/index.cjs CHANGED
@@ -170,7 +170,7 @@ var DBI = class DBI {
170
170
  /**
171
171
  * The RocksDB context for `get()`, `put()`, and `remove()`.
172
172
  */
173
- #context;
173
+ _context;
174
174
  /**
175
175
  * The database store instance. The store instance is tied to the database
176
176
  * instance and shared with transaction instances.
@@ -185,7 +185,7 @@ var DBI = class DBI {
185
185
  constructor(store, transaction) {
186
186
  if (new.target === DBI) throw new Error("DBI is an abstract class and cannot be instantiated directly");
187
187
  this.store = store;
188
- this.#context = transaction || store.db;
188
+ this._context = transaction || store.db;
189
189
  }
190
190
  /**
191
191
  * Adds a listener for the given key.
@@ -216,14 +216,14 @@ var DBI = class DBI {
216
216
  */
217
217
  getBinary(key, options) {
218
218
  if (!this.store.isOpen()) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
219
- return this.store.get(this.#context, key, true, this.store.getTxnId(options));
219
+ return this.store.get(this._context, key, true, this.store.getTxnId(options));
220
220
  }
221
221
  /**
222
222
  * Synchronously retrieves the binary data for the given key.
223
223
  */
224
224
  getBinarySync(key, options) {
225
225
  if (!this.store.isOpen()) throw new Error("Database not open");
226
- return this.store.getSync(this.#context, key, true, options);
226
+ return this.store.getSync(this._context, key, true, options);
227
227
  }
228
228
  /**
229
229
  * Retrieves the binary data for the given key using a preallocated,
@@ -237,7 +237,7 @@ var DBI = class DBI {
237
237
  */
238
238
  getBinaryFast(key, options) {
239
239
  if (!this.store.isOpen()) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
240
- return this.store.get(this.#context, key, false, this.store.getTxnId(options));
240
+ return this.store.get(this._context, key, false, this.store.getTxnId(options));
241
241
  }
242
242
  /**
243
243
  * Synchronously retrieves the binary data for the given key using a
@@ -246,16 +246,13 @@ var DBI = class DBI {
246
246
  */
247
247
  getBinaryFastSync(key, options) {
248
248
  if (!this.store.isOpen()) throw new Error("Database not open");
249
- return this.store.getSync(this.#context, key, false, options);
249
+ return this.store.getSync(this._context, key, false, options);
250
250
  }
251
251
  /**
252
252
  * Retrieves all keys within a range.
253
253
  */
254
254
  getKeys(options) {
255
- return this.store.getRange(this.#context, {
256
- ...options,
257
- values: false
258
- }).map((item) => item.key);
255
+ return this.store.getKeys(this._context, options);
259
256
  }
260
257
  /**
261
258
  * Retrieves the number of keys within a range.
@@ -270,7 +267,7 @@ var DBI = class DBI {
270
267
  * ```
271
268
  */
272
269
  getKeysCount(options) {
273
- return this.store.getCount(this.#context, options);
270
+ return this.store.getKeysCount(this._context, options);
274
271
  }
275
272
  /**
276
273
  * Retrieves a range of keys and their values.
@@ -290,7 +287,7 @@ var DBI = class DBI {
290
287
  * ```
291
288
  */
292
289
  getRange(options) {
293
- return this.store.getRange(this.#context, options);
290
+ return this.store.getRange(this._context, options);
294
291
  }
295
292
  /**
296
293
  * Synchronously retrieves the value for the given key, then returns the
@@ -307,7 +304,7 @@ var DBI = class DBI {
307
304
  return result ? this.store.decodeValue(result) : void 0;
308
305
  }
309
306
  if (!this.store.isOpen()) throw new Error("Database not open");
310
- return this.store.decodeValue(this.store.getSync(this.#context, key, true, options));
307
+ return this.store.decodeValue(this.store.getSync(this._context, key, true, options));
311
308
  }
312
309
  /**
313
310
  * Gets the number of listeners for the given key.
@@ -376,7 +373,7 @@ var DBI = class DBI {
376
373
  * ```
377
374
  */
378
375
  async put(key, value, options) {
379
- return this.store.putSync(this.#context, key, value, options);
376
+ return this.store.putSync(this._context, key, value, options);
380
377
  }
381
378
  /**
382
379
  * Synchronously stores a value for the given key.
@@ -392,7 +389,7 @@ var DBI = class DBI {
392
389
  * ```
393
390
  */
394
391
  putSync(key, value, options) {
395
- return this.store.putSync(this.#context, key, value, options);
392
+ return this.store.putSync(this._context, key, value, options);
396
393
  }
397
394
  /**
398
395
  * Removes a value for the given key. If the key does not exist, it will
@@ -408,7 +405,7 @@ var DBI = class DBI {
408
405
  * ```
409
406
  */
410
407
  async remove(key, options) {
411
- return this.store.removeSync(this.#context, key, options);
408
+ return this.store.removeSync(this._context, key, options);
412
409
  }
413
410
  /**
414
411
  * Removes a value for the given key. If the key does not exist, it will
@@ -424,7 +421,7 @@ var DBI = class DBI {
424
421
  * ```
425
422
  */
426
423
  removeSync(key, options) {
427
- return this.store.removeSync(this.#context, key, options);
424
+ return this.store.removeSync(this._context, key, options);
428
425
  }
429
426
  /**
430
427
  * Removes an event listener. You must specify the exact same callback that was
@@ -443,7 +440,7 @@ var DBI = class DBI {
443
440
  * @returns The transaction log.
444
441
  */
445
442
  useLog(name) {
446
- return this.store.useLog(this.#context, name);
443
+ return this.store.useLog(this._context, name);
447
444
  }
448
445
  };
449
446
 
@@ -800,6 +797,15 @@ var Store = class {
800
797
  }
801
798
  return context.getCount(options, this.getTxnId(options));
802
799
  }
800
+ getKeys(context, options) {
801
+ return this.getRange(context, {
802
+ ...options,
803
+ values: false
804
+ }).map((item) => item.key);
805
+ }
806
+ getKeysCount(context, options) {
807
+ return this.getCount(context, options);
808
+ }
803
809
  getRange(context, options) {
804
810
  if (!this.db.opened) throw new Error("Database not open");
805
811
  options = { ...options };
@@ -1805,10 +1811,11 @@ function loadLastPosition(transactionLog, readUncommitted) {
1805
1811
  //#region src/index.ts
1806
1812
  const versions = {
1807
1813
  rocksdb: version,
1808
- "rocksdb-js": "0.1.3"
1814
+ "rocksdb-js": "0.1.4"
1809
1815
  };
1810
1816
 
1811
1817
  //#endregion
1818
+ exports.DBI = DBI;
1812
1819
  exports.DBIterator = DBIterator;
1813
1820
  exports.RocksDatabase = RocksDatabase;
1814
1821
  exports.Store = Store;