@harperfast/rocksdb-js 0.1.2 → 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 +62 -7
- package/dist/index.cjs +41 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -10
- package/dist/index.d.mts +38 -10
- package/dist/index.mjs +39 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
package/dist/index.d.cts
CHANGED
|
@@ -50,7 +50,12 @@ declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
|
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/store.d.ts
|
|
53
|
-
type
|
|
53
|
+
type StoreContext = NativeDatabase | NativeTransaction;
|
|
54
|
+
type StoreGetOptions = GetOptions & DBITransactional;
|
|
55
|
+
type StoreIteratorOptions = IteratorOptions & DBITransactional;
|
|
56
|
+
type StorePutOptions = PutOptions & DBITransactional;
|
|
57
|
+
type StoreRangeOptions = RangeOptions & DBITransactional;
|
|
58
|
+
type StoreRemoveOptions = DBITransactional | unknown;
|
|
54
59
|
/**
|
|
55
60
|
* Options for the `Store` class.
|
|
56
61
|
*/
|
|
@@ -248,10 +253,12 @@ declare class Store {
|
|
|
248
253
|
* @returns The encoded value.
|
|
249
254
|
*/
|
|
250
255
|
encodeValue(value: any): BufferWithDataView | Uint8Array;
|
|
251
|
-
get(context:
|
|
252
|
-
getCount(context:
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
get(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, txnId?: number): any | undefined;
|
|
257
|
+
getCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
258
|
+
getKeys(context: StoreContext, options?: StoreIteratorOptions): any | undefined;
|
|
259
|
+
getKeysCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
260
|
+
getRange(context: StoreContext, options?: StoreIteratorOptions): ExtendedIterable<DBIteratorValue<any>>;
|
|
261
|
+
getSync(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, options?: StoreGetOptions): any | undefined;
|
|
255
262
|
/**
|
|
256
263
|
* Checks if the data method options object contains a transaction ID and
|
|
257
264
|
* returns it.
|
|
@@ -294,8 +301,8 @@ declare class Store {
|
|
|
294
301
|
* are performed.
|
|
295
302
|
*/
|
|
296
303
|
open(): boolean;
|
|
297
|
-
putSync(context:
|
|
298
|
-
removeSync(context:
|
|
304
|
+
putSync(context: StoreContext, key: Key, value: any, options?: StorePutOptions): void;
|
|
305
|
+
removeSync(context: StoreContext, key: Key, options?: StoreRemoveOptions): void;
|
|
299
306
|
/**
|
|
300
307
|
* Attempts to acquire a lock for a given key. If the lock is available,
|
|
301
308
|
* the function returns `true` and the optional callback is never called.
|
|
@@ -321,7 +328,7 @@ declare class Store {
|
|
|
321
328
|
* @param name - The name of the transaction log.
|
|
322
329
|
* @returns The transaction log.
|
|
323
330
|
*/
|
|
324
|
-
useLog(context:
|
|
331
|
+
useLog(context: StoreContext, name: string | number): TransactionLog;
|
|
325
332
|
/**
|
|
326
333
|
* Acquires a lock on the given key and calls the callback.
|
|
327
334
|
*
|
|
@@ -427,6 +434,7 @@ type NativeDatabase = {
|
|
|
427
434
|
clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
428
435
|
clearSync(): void;
|
|
429
436
|
close(): void;
|
|
437
|
+
destroy(): void;
|
|
430
438
|
drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
431
439
|
dropSync(): void;
|
|
432
440
|
flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
@@ -459,6 +467,17 @@ type NativeDatabase = {
|
|
|
459
467
|
type RocksDatabaseConfig = {
|
|
460
468
|
blockCacheSize?: number;
|
|
461
469
|
};
|
|
470
|
+
type RegistryStatusDB = {
|
|
471
|
+
path: string;
|
|
472
|
+
refCount: number;
|
|
473
|
+
columnFamilies: string[];
|
|
474
|
+
transactions: number;
|
|
475
|
+
closables: number;
|
|
476
|
+
locks: number;
|
|
477
|
+
userSharedBuffers: number;
|
|
478
|
+
listenerCallbacks: number;
|
|
479
|
+
};
|
|
480
|
+
type RegistryStatus = RegistryStatusDB[];
|
|
462
481
|
declare const constants: {
|
|
463
482
|
TRANSACTION_LOG_TOKEN: number;
|
|
464
483
|
TRANSACTION_LOG_FILE_HEADER_SIZE: number;
|
|
@@ -470,6 +489,7 @@ declare const constants: {
|
|
|
470
489
|
declare const NativeDatabase: NativeDatabase;
|
|
471
490
|
declare const NativeTransaction: NativeTransaction;
|
|
472
491
|
declare const TransactionLog: TransactionLog;
|
|
492
|
+
declare const registryStatus: () => RegistryStatus;
|
|
473
493
|
declare const shutdown: () => void;
|
|
474
494
|
//#endregion
|
|
475
495
|
//#region src/transaction.d.ts
|
|
@@ -626,7 +646,10 @@ interface DBITransactional {
|
|
|
626
646
|
* This class is not meant to be used directly.
|
|
627
647
|
*/
|
|
628
648
|
declare class DBI<T extends DBITransactional | unknown = unknown> {
|
|
629
|
-
|
|
649
|
+
/**
|
|
650
|
+
* The RocksDB context for `get()`, `put()`, and `remove()`.
|
|
651
|
+
*/
|
|
652
|
+
_context: StoreContext;
|
|
630
653
|
/**
|
|
631
654
|
* The database store instance. The store instance is tied to the database
|
|
632
655
|
* instance and shared with transaction instances.
|
|
@@ -893,6 +916,7 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
893
916
|
* ```
|
|
894
917
|
*/
|
|
895
918
|
static config(options: RocksDatabaseConfig): void;
|
|
919
|
+
destroy(): void;
|
|
896
920
|
drop(): Promise<void>;
|
|
897
921
|
dropSync(): void;
|
|
898
922
|
get encoder(): Encoder | null;
|
|
@@ -1041,6 +1065,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
1041
1065
|
*/
|
|
1042
1066
|
purgeLogs(options?: PurgeLogsOptions): string[];
|
|
1043
1067
|
/**
|
|
1068
|
+
* The status of the database.
|
|
1069
|
+
*/
|
|
1070
|
+
get status(): "open" | "closed";
|
|
1071
|
+
/**
|
|
1044
1072
|
* Executes all operations in the callback as a single transaction.
|
|
1045
1073
|
*
|
|
1046
1074
|
* @param callback - A async function that receives the transaction as an argument.
|
|
@@ -1153,5 +1181,5 @@ declare const versions: {
|
|
|
1153
1181
|
"rocksdb-js": string;
|
|
1154
1182
|
};
|
|
1155
1183
|
//#endregion
|
|
1156
|
-
export {
|
|
1184
|
+
export { DBI, DBIterator, type IteratorOptions, type Key, RocksDatabase, type RocksDatabaseOptions, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
|
|
1157
1185
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -50,7 +50,12 @@ declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
|
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/store.d.ts
|
|
53
|
-
type
|
|
53
|
+
type StoreContext = NativeDatabase | NativeTransaction;
|
|
54
|
+
type StoreGetOptions = GetOptions & DBITransactional;
|
|
55
|
+
type StoreIteratorOptions = IteratorOptions & DBITransactional;
|
|
56
|
+
type StorePutOptions = PutOptions & DBITransactional;
|
|
57
|
+
type StoreRangeOptions = RangeOptions & DBITransactional;
|
|
58
|
+
type StoreRemoveOptions = DBITransactional | unknown;
|
|
54
59
|
/**
|
|
55
60
|
* Options for the `Store` class.
|
|
56
61
|
*/
|
|
@@ -248,10 +253,12 @@ declare class Store {
|
|
|
248
253
|
* @returns The encoded value.
|
|
249
254
|
*/
|
|
250
255
|
encodeValue(value: any): BufferWithDataView | Uint8Array;
|
|
251
|
-
get(context:
|
|
252
|
-
getCount(context:
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
get(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, txnId?: number): any | undefined;
|
|
257
|
+
getCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
258
|
+
getKeys(context: StoreContext, options?: StoreIteratorOptions): any | undefined;
|
|
259
|
+
getKeysCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
260
|
+
getRange(context: StoreContext, options?: StoreIteratorOptions): ExtendedIterable<DBIteratorValue<any>>;
|
|
261
|
+
getSync(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, options?: StoreGetOptions): any | undefined;
|
|
255
262
|
/**
|
|
256
263
|
* Checks if the data method options object contains a transaction ID and
|
|
257
264
|
* returns it.
|
|
@@ -294,8 +301,8 @@ declare class Store {
|
|
|
294
301
|
* are performed.
|
|
295
302
|
*/
|
|
296
303
|
open(): boolean;
|
|
297
|
-
putSync(context:
|
|
298
|
-
removeSync(context:
|
|
304
|
+
putSync(context: StoreContext, key: Key, value: any, options?: StorePutOptions): void;
|
|
305
|
+
removeSync(context: StoreContext, key: Key, options?: StoreRemoveOptions): void;
|
|
299
306
|
/**
|
|
300
307
|
* Attempts to acquire a lock for a given key. If the lock is available,
|
|
301
308
|
* the function returns `true` and the optional callback is never called.
|
|
@@ -321,7 +328,7 @@ declare class Store {
|
|
|
321
328
|
* @param name - The name of the transaction log.
|
|
322
329
|
* @returns The transaction log.
|
|
323
330
|
*/
|
|
324
|
-
useLog(context:
|
|
331
|
+
useLog(context: StoreContext, name: string | number): TransactionLog;
|
|
325
332
|
/**
|
|
326
333
|
* Acquires a lock on the given key and calls the callback.
|
|
327
334
|
*
|
|
@@ -427,6 +434,7 @@ type NativeDatabase = {
|
|
|
427
434
|
clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
428
435
|
clearSync(): void;
|
|
429
436
|
close(): void;
|
|
437
|
+
destroy(): void;
|
|
430
438
|
drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
431
439
|
dropSync(): void;
|
|
432
440
|
flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
@@ -459,6 +467,17 @@ type NativeDatabase = {
|
|
|
459
467
|
type RocksDatabaseConfig = {
|
|
460
468
|
blockCacheSize?: number;
|
|
461
469
|
};
|
|
470
|
+
type RegistryStatusDB = {
|
|
471
|
+
path: string;
|
|
472
|
+
refCount: number;
|
|
473
|
+
columnFamilies: string[];
|
|
474
|
+
transactions: number;
|
|
475
|
+
closables: number;
|
|
476
|
+
locks: number;
|
|
477
|
+
userSharedBuffers: number;
|
|
478
|
+
listenerCallbacks: number;
|
|
479
|
+
};
|
|
480
|
+
type RegistryStatus = RegistryStatusDB[];
|
|
462
481
|
declare const constants: {
|
|
463
482
|
TRANSACTION_LOG_TOKEN: number;
|
|
464
483
|
TRANSACTION_LOG_FILE_HEADER_SIZE: number;
|
|
@@ -470,6 +489,7 @@ declare const constants: {
|
|
|
470
489
|
declare const NativeDatabase: NativeDatabase;
|
|
471
490
|
declare const NativeTransaction: NativeTransaction;
|
|
472
491
|
declare const TransactionLog: TransactionLog;
|
|
492
|
+
declare const registryStatus: () => RegistryStatus;
|
|
473
493
|
declare const shutdown: () => void;
|
|
474
494
|
//#endregion
|
|
475
495
|
//#region src/transaction.d.ts
|
|
@@ -626,7 +646,10 @@ interface DBITransactional {
|
|
|
626
646
|
* This class is not meant to be used directly.
|
|
627
647
|
*/
|
|
628
648
|
declare class DBI<T extends DBITransactional | unknown = unknown> {
|
|
629
|
-
|
|
649
|
+
/**
|
|
650
|
+
* The RocksDB context for `get()`, `put()`, and `remove()`.
|
|
651
|
+
*/
|
|
652
|
+
_context: StoreContext;
|
|
630
653
|
/**
|
|
631
654
|
* The database store instance. The store instance is tied to the database
|
|
632
655
|
* instance and shared with transaction instances.
|
|
@@ -893,6 +916,7 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
893
916
|
* ```
|
|
894
917
|
*/
|
|
895
918
|
static config(options: RocksDatabaseConfig): void;
|
|
919
|
+
destroy(): void;
|
|
896
920
|
drop(): Promise<void>;
|
|
897
921
|
dropSync(): void;
|
|
898
922
|
get encoder(): Encoder | null;
|
|
@@ -1041,6 +1065,10 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
1041
1065
|
*/
|
|
1042
1066
|
purgeLogs(options?: PurgeLogsOptions): string[];
|
|
1043
1067
|
/**
|
|
1068
|
+
* The status of the database.
|
|
1069
|
+
*/
|
|
1070
|
+
get status(): "open" | "closed";
|
|
1071
|
+
/**
|
|
1044
1072
|
* Executes all operations in the callback as a single transaction.
|
|
1045
1073
|
*
|
|
1046
1074
|
* @param callback - A async function that receives the transaction as an argument.
|
|
@@ -1153,5 +1181,5 @@ declare const versions: {
|
|
|
1153
1181
|
"rocksdb-js": string;
|
|
1154
1182
|
};
|
|
1155
1183
|
//#endregion
|
|
1156
|
-
export {
|
|
1184
|
+
export { DBI, DBIterator, type IteratorOptions, type Key, RocksDatabase, type RocksDatabaseOptions, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
|
|
1157
1185
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { Encoder } from "msgpackr";
|
|
|
7
7
|
import * as orderedBinary from "ordered-binary";
|
|
8
8
|
import { ExtendedIterable } from "@harperfast/extended-iterable";
|
|
9
9
|
|
|
10
|
-
//#region
|
|
10
|
+
//#region \0rolldown/runtime.js
|
|
11
11
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
@@ -55,8 +55,9 @@ const NativeDatabase = binding.Database;
|
|
|
55
55
|
const NativeIterator = binding.Iterator;
|
|
56
56
|
const NativeTransaction = binding.Transaction;
|
|
57
57
|
const TransactionLog = binding.TransactionLog;
|
|
58
|
-
const
|
|
58
|
+
const registryStatus = binding.registryStatus;
|
|
59
59
|
const shutdown = binding.shutdown;
|
|
60
|
+
const version = binding.version;
|
|
60
61
|
|
|
61
62
|
//#endregion
|
|
62
63
|
//#region src/util.ts
|
|
@@ -144,7 +145,7 @@ var DBI = class DBI {
|
|
|
144
145
|
/**
|
|
145
146
|
* The RocksDB context for `get()`, `put()`, and `remove()`.
|
|
146
147
|
*/
|
|
147
|
-
|
|
148
|
+
_context;
|
|
148
149
|
/**
|
|
149
150
|
* The database store instance. The store instance is tied to the database
|
|
150
151
|
* instance and shared with transaction instances.
|
|
@@ -159,7 +160,7 @@ var DBI = class DBI {
|
|
|
159
160
|
constructor(store, transaction) {
|
|
160
161
|
if (new.target === DBI) throw new Error("DBI is an abstract class and cannot be instantiated directly");
|
|
161
162
|
this.store = store;
|
|
162
|
-
this
|
|
163
|
+
this._context = transaction || store.db;
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
165
166
|
* Adds a listener for the given key.
|
|
@@ -190,14 +191,14 @@ var DBI = class DBI {
|
|
|
190
191
|
*/
|
|
191
192
|
getBinary(key, options) {
|
|
192
193
|
if (!this.store.isOpen()) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
|
|
193
|
-
return this.store.get(this
|
|
194
|
+
return this.store.get(this._context, key, true, this.store.getTxnId(options));
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
197
|
* Synchronously retrieves the binary data for the given key.
|
|
197
198
|
*/
|
|
198
199
|
getBinarySync(key, options) {
|
|
199
200
|
if (!this.store.isOpen()) throw new Error("Database not open");
|
|
200
|
-
return this.store.getSync(this
|
|
201
|
+
return this.store.getSync(this._context, key, true, options);
|
|
201
202
|
}
|
|
202
203
|
/**
|
|
203
204
|
* Retrieves the binary data for the given key using a preallocated,
|
|
@@ -211,7 +212,7 @@ var DBI = class DBI {
|
|
|
211
212
|
*/
|
|
212
213
|
getBinaryFast(key, options) {
|
|
213
214
|
if (!this.store.isOpen()) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
|
|
214
|
-
return this.store.get(this
|
|
215
|
+
return this.store.get(this._context, key, false, this.store.getTxnId(options));
|
|
215
216
|
}
|
|
216
217
|
/**
|
|
217
218
|
* Synchronously retrieves the binary data for the given key using a
|
|
@@ -220,16 +221,13 @@ var DBI = class DBI {
|
|
|
220
221
|
*/
|
|
221
222
|
getBinaryFastSync(key, options) {
|
|
222
223
|
if (!this.store.isOpen()) throw new Error("Database not open");
|
|
223
|
-
return this.store.getSync(this
|
|
224
|
+
return this.store.getSync(this._context, key, false, options);
|
|
224
225
|
}
|
|
225
226
|
/**
|
|
226
227
|
* Retrieves all keys within a range.
|
|
227
228
|
*/
|
|
228
229
|
getKeys(options) {
|
|
229
|
-
return this.store.
|
|
230
|
-
...options,
|
|
231
|
-
values: false
|
|
232
|
-
}).map((item) => item.key);
|
|
230
|
+
return this.store.getKeys(this._context, options);
|
|
233
231
|
}
|
|
234
232
|
/**
|
|
235
233
|
* Retrieves the number of keys within a range.
|
|
@@ -244,7 +242,7 @@ var DBI = class DBI {
|
|
|
244
242
|
* ```
|
|
245
243
|
*/
|
|
246
244
|
getKeysCount(options) {
|
|
247
|
-
return this.store.
|
|
245
|
+
return this.store.getKeysCount(this._context, options);
|
|
248
246
|
}
|
|
249
247
|
/**
|
|
250
248
|
* Retrieves a range of keys and their values.
|
|
@@ -264,7 +262,7 @@ var DBI = class DBI {
|
|
|
264
262
|
* ```
|
|
265
263
|
*/
|
|
266
264
|
getRange(options) {
|
|
267
|
-
return this.store.getRange(this
|
|
265
|
+
return this.store.getRange(this._context, options);
|
|
268
266
|
}
|
|
269
267
|
/**
|
|
270
268
|
* Synchronously retrieves the value for the given key, then returns the
|
|
@@ -281,7 +279,7 @@ var DBI = class DBI {
|
|
|
281
279
|
return result ? this.store.decodeValue(result) : void 0;
|
|
282
280
|
}
|
|
283
281
|
if (!this.store.isOpen()) throw new Error("Database not open");
|
|
284
|
-
return this.store.decodeValue(this.store.getSync(this
|
|
282
|
+
return this.store.decodeValue(this.store.getSync(this._context, key, true, options));
|
|
285
283
|
}
|
|
286
284
|
/**
|
|
287
285
|
* Gets the number of listeners for the given key.
|
|
@@ -350,7 +348,7 @@ var DBI = class DBI {
|
|
|
350
348
|
* ```
|
|
351
349
|
*/
|
|
352
350
|
async put(key, value, options) {
|
|
353
|
-
return this.store.putSync(this
|
|
351
|
+
return this.store.putSync(this._context, key, value, options);
|
|
354
352
|
}
|
|
355
353
|
/**
|
|
356
354
|
* Synchronously stores a value for the given key.
|
|
@@ -366,7 +364,7 @@ var DBI = class DBI {
|
|
|
366
364
|
* ```
|
|
367
365
|
*/
|
|
368
366
|
putSync(key, value, options) {
|
|
369
|
-
return this.store.putSync(this
|
|
367
|
+
return this.store.putSync(this._context, key, value, options);
|
|
370
368
|
}
|
|
371
369
|
/**
|
|
372
370
|
* Removes a value for the given key. If the key does not exist, it will
|
|
@@ -382,7 +380,7 @@ var DBI = class DBI {
|
|
|
382
380
|
* ```
|
|
383
381
|
*/
|
|
384
382
|
async remove(key, options) {
|
|
385
|
-
return this.store.removeSync(this
|
|
383
|
+
return this.store.removeSync(this._context, key, options);
|
|
386
384
|
}
|
|
387
385
|
/**
|
|
388
386
|
* Removes a value for the given key. If the key does not exist, it will
|
|
@@ -398,7 +396,7 @@ var DBI = class DBI {
|
|
|
398
396
|
* ```
|
|
399
397
|
*/
|
|
400
398
|
removeSync(key, options) {
|
|
401
|
-
return this.store.removeSync(this
|
|
399
|
+
return this.store.removeSync(this._context, key, options);
|
|
402
400
|
}
|
|
403
401
|
/**
|
|
404
402
|
* Removes an event listener. You must specify the exact same callback that was
|
|
@@ -417,7 +415,7 @@ var DBI = class DBI {
|
|
|
417
415
|
* @returns The transaction log.
|
|
418
416
|
*/
|
|
419
417
|
useLog(name) {
|
|
420
|
-
return this.store.useLog(this
|
|
418
|
+
return this.store.useLog(this._context, name);
|
|
421
419
|
}
|
|
422
420
|
};
|
|
423
421
|
|
|
@@ -774,6 +772,15 @@ var Store = class {
|
|
|
774
772
|
}
|
|
775
773
|
return context.getCount(options, this.getTxnId(options));
|
|
776
774
|
}
|
|
775
|
+
getKeys(context, options) {
|
|
776
|
+
return this.getRange(context, {
|
|
777
|
+
...options,
|
|
778
|
+
values: false
|
|
779
|
+
}).map((item) => item.key);
|
|
780
|
+
}
|
|
781
|
+
getKeysCount(context, options) {
|
|
782
|
+
return this.getCount(context, options);
|
|
783
|
+
}
|
|
777
784
|
getRange(context, options) {
|
|
778
785
|
if (!this.db.opened) throw new Error("Database not open");
|
|
779
786
|
options = { ...options };
|
|
@@ -1075,7 +1082,6 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1075
1082
|
* ```
|
|
1076
1083
|
*/
|
|
1077
1084
|
clear() {
|
|
1078
|
-
if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
|
|
1079
1085
|
if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
|
|
1080
1086
|
return new Promise((resolve, reject) => {
|
|
1081
1087
|
this.store.db.clear(resolve, reject);
|
|
@@ -1091,9 +1097,8 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1091
1097
|
* ```
|
|
1092
1098
|
*/
|
|
1093
1099
|
clearSync() {
|
|
1094
|
-
if (!this.store.db.opened) throw new Error("Database not open");
|
|
1095
1100
|
if (this.store.encoder?.structures !== void 0) this.store.encoder.structures = [];
|
|
1096
|
-
|
|
1101
|
+
this.store.db.clearSync();
|
|
1097
1102
|
}
|
|
1098
1103
|
/**
|
|
1099
1104
|
* Closes the database.
|
|
@@ -1120,14 +1125,15 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1120
1125
|
static config(options) {
|
|
1121
1126
|
config(options);
|
|
1122
1127
|
}
|
|
1128
|
+
destroy() {
|
|
1129
|
+
this.store.db.destroy();
|
|
1130
|
+
}
|
|
1123
1131
|
async drop() {
|
|
1124
|
-
if (!this.store.db.opened) return Promise.reject(/* @__PURE__ */ new Error("Database not open"));
|
|
1125
1132
|
return new Promise((resolve, reject) => {
|
|
1126
1133
|
this.store.db.drop(resolve, reject);
|
|
1127
1134
|
});
|
|
1128
1135
|
}
|
|
1129
1136
|
dropSync() {
|
|
1130
|
-
if (!this.store.db.opened) throw new Error("Database not open");
|
|
1131
1137
|
return this.store.db.dropSync();
|
|
1132
1138
|
}
|
|
1133
1139
|
get encoder() {
|
|
@@ -1386,6 +1392,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1386
1392
|
return this.store.db.purgeLogs(options);
|
|
1387
1393
|
}
|
|
1388
1394
|
/**
|
|
1395
|
+
* The status of the database.
|
|
1396
|
+
*/
|
|
1397
|
+
get status() {
|
|
1398
|
+
return this.store.isOpen() ? "open" : "closed";
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1389
1401
|
* Executes all operations in the callback as a single transaction.
|
|
1390
1402
|
*
|
|
1391
1403
|
* @param callback - A async function that receives the transaction as an argument.
|
|
@@ -1774,9 +1786,9 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
1774
1786
|
//#region src/index.ts
|
|
1775
1787
|
const versions = {
|
|
1776
1788
|
rocksdb: version,
|
|
1777
|
-
"rocksdb-js": "0.1.
|
|
1789
|
+
"rocksdb-js": "0.1.4"
|
|
1778
1790
|
};
|
|
1779
1791
|
|
|
1780
1792
|
//#endregion
|
|
1781
|
-
export { DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, shutdown, versions };
|
|
1793
|
+
export { DBI, DBIterator, RocksDatabase, Store, Transaction, TransactionLog, constants, parseTransactionLog, registryStatus, shutdown, versions };
|
|
1782
1794
|
//# sourceMappingURL=index.mjs.map
|