@harperfast/rocksdb-js 1.1.0 → 1.1.1
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 +19 -3
- package/dist/index.cjs +18 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -19
- package/dist/index.d.mts +27 -19
- package/dist/index.mjs +18 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -85,6 +85,18 @@ const db = RocksDatabase.open('foo');
|
|
|
85
85
|
db.close();
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
### `db.columns: string[]`
|
|
89
|
+
|
|
90
|
+
Returns the list of column families in the RocksDB database.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const db = RocksDatabase.open('path/to/db');
|
|
94
|
+
console.log(db.columns); // ['default']
|
|
95
|
+
|
|
96
|
+
const db2 = new RocksDatabase('path/to/db', { name: 'users' });
|
|
97
|
+
console.log(db.columns); // ['default', 'users']
|
|
98
|
+
```
|
|
99
|
+
|
|
88
100
|
### `db.config(options)`
|
|
89
101
|
|
|
90
102
|
Sets global database settings.
|
|
@@ -290,24 +302,28 @@ await promise;
|
|
|
290
302
|
console.log(db.getOldestSnapshotTimestamp()); // returns `0`, no snapshots
|
|
291
303
|
```
|
|
292
304
|
|
|
293
|
-
### `db.getDBProperty(propertyName: string): string`
|
|
305
|
+
### `db.getDBProperty(propertyName: string): string | undefined`
|
|
294
306
|
|
|
295
307
|
Gets a RocksDB database property as a string.
|
|
296
308
|
|
|
297
309
|
- `propertyName: string` The name of the property to retrieve (e.g., ) `'rocksdb.levelstats'`.
|
|
298
310
|
|
|
311
|
+
Returns `undefined` if the property is not found.
|
|
312
|
+
|
|
299
313
|
```typescript
|
|
300
314
|
const db = RocksDatabase.open('/path/to/database');
|
|
301
315
|
const levelStats = db.getDBProperty('rocksdb.levelstats');
|
|
302
316
|
const stats = db.getDBProperty('rocksdb.stats');
|
|
303
317
|
```
|
|
304
318
|
|
|
305
|
-
### `db.getDBIntProperty(propertyName: string): number`
|
|
319
|
+
### `db.getDBIntProperty(propertyName: string): number | undefined`
|
|
306
320
|
|
|
307
321
|
Gets a RocksDB database property as an integer.
|
|
308
322
|
|
|
309
323
|
- `propertyName: string` The name of the property to retrieve (e.g., ) `'rocksdb.num-blob-files'`.
|
|
310
324
|
|
|
325
|
+
Returns `undefined` if the property is not found.
|
|
326
|
+
|
|
311
327
|
```typescript
|
|
312
328
|
const db = RocksDatabase.open('/path/to/database');
|
|
313
329
|
const blobFiles = db.getDBIntProperty('rocksdb.num-blob-files');
|
|
@@ -399,7 +415,7 @@ Synchronous version of `remove()`.
|
|
|
399
415
|
|
|
400
416
|
## Transactions
|
|
401
417
|
|
|
402
|
-
### `db.transaction<T>(callback: TransactionCallback<T>, options?:
|
|
418
|
+
### `db.transaction<T>(callback: TransactionCallback<T>, options?: TransactionOptions): Promise<T>`
|
|
403
419
|
|
|
404
420
|
Executes all database operations within the specified callback within a single transaction. If the
|
|
405
421
|
callback completes without error, the database operations are automatically committed. However, if
|
package/dist/index.cjs
CHANGED
|
@@ -1219,6 +1219,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1219
1219
|
this.store.close();
|
|
1220
1220
|
}
|
|
1221
1221
|
/**
|
|
1222
|
+
* Returns the list of column families in the RocksDB database.
|
|
1223
|
+
*/
|
|
1224
|
+
get columns() {
|
|
1225
|
+
return this.store.db.columns;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1222
1228
|
* Set global database settings.
|
|
1223
1229
|
*
|
|
1224
1230
|
* @param options - The options for the database.
|
|
@@ -1462,14 +1468,14 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1462
1468
|
return buffer && store.decoder?.decode ? store.decoder.decode(buffer) : void 0;
|
|
1463
1469
|
};
|
|
1464
1470
|
opts.saveStructures = (structures, isCompatible) => {
|
|
1465
|
-
return this.transactionSync((txn) => {
|
|
1471
|
+
return this.transactionSync((txn, _attempt) => {
|
|
1466
1472
|
const existingStructuresBuffer = this.getBinarySync(sharedStructuresKey);
|
|
1467
1473
|
const existingStructures = existingStructuresBuffer && store.decoder?.decode ? store.decoder.decode(existingStructuresBuffer) : void 0;
|
|
1468
1474
|
if (typeof isCompatible == "function") {
|
|
1469
1475
|
if (!isCompatible(existingStructures)) return false;
|
|
1470
1476
|
} else if (existingStructures && existingStructures.length !== isCompatible) return false;
|
|
1471
1477
|
txn.putSync(sharedStructuresKey, structures);
|
|
1472
|
-
});
|
|
1478
|
+
}, { retryOnBusy: true });
|
|
1473
1479
|
};
|
|
1474
1480
|
}
|
|
1475
1481
|
store.encoder = new EncoderClass({
|
|
@@ -1486,16 +1492,15 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1486
1492
|
};
|
|
1487
1493
|
store.decoder = store.encoder;
|
|
1488
1494
|
}
|
|
1489
|
-
if (typeof store.encoder?.writeKey === "function" && !store.encoder?.encode) {
|
|
1490
|
-
store.encoder
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1495
|
+
if (typeof store.encoder?.writeKey === "function" && !store.encoder?.encode) store.encoder = {
|
|
1496
|
+
...store.encoder,
|
|
1497
|
+
encode: (value, _mode) => {
|
|
1498
|
+
const bytesWritten = store.writeKey(value, store.encodeBuffer, 0);
|
|
1499
|
+
return store.encodeBuffer.subarray(0, bytesWritten);
|
|
1500
|
+
},
|
|
1501
|
+
copyBuffers: true
|
|
1502
|
+
};
|
|
1503
|
+
if (store.encoder) store.encoder.name = this.#name;
|
|
1499
1504
|
if (store.decoder && store.decoder.needsStableBuffer !== true) store.decoderCopies = true;
|
|
1500
1505
|
if (store.decoder?.readKey && !store.decoder.decode) {
|
|
1501
1506
|
store.decoder.decode = (buffer) => {
|
|
@@ -1931,7 +1936,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
1931
1936
|
//#region src/index.ts
|
|
1932
1937
|
const versions = {
|
|
1933
1938
|
rocksdb: version,
|
|
1934
|
-
"rocksdb-js": "1.1.
|
|
1939
|
+
"rocksdb-js": "1.1.1"
|
|
1935
1940
|
};
|
|
1936
1941
|
|
|
1937
1942
|
//#endregion
|