@harperfast/rocksdb-js 0.1.0 → 0.1.2

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
@@ -108,6 +108,18 @@ There's also a static `open()` method for convenience that performs the same thi
108
108
  const db = RocksDatabase.open('path/to/db');
109
109
  ```
110
110
 
111
+ ### `db.name: string`
112
+
113
+ Returns the database column family's name.
114
+
115
+ ```typescript
116
+ const db = new RocksDatabase('path/to/db');
117
+ console.log(db.name); // 'default'
118
+
119
+ const db2 = new RocksDatabase('path/to/db', { name: 'users' });
120
+ console.log(db.name); // 'users'
121
+ ```
122
+
111
123
  ## Data Operations
112
124
 
113
125
  ### `db.clear(options?): Promise<number>`
package/dist/index.cjs CHANGED
@@ -37,6 +37,7 @@ let _harperfast_extended_iterable = require("@harperfast/extended-iterable");
37
37
 
38
38
  //#region src/load-binding.ts
39
39
  const nativeExtRE = /\.node$/;
40
+ const req = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
40
41
  /**
41
42
  * Locates the native binding in the `build` directory, then the `prebuilds`
42
43
  * directory.
@@ -67,12 +68,11 @@ function locateBinding() {
67
68
  }
68
69
  /* v8 ignore next 10 -- @preserve */
69
70
  try {
70
- const path = (0, node_path.join)(baseDir, "node_modules", "@harperfast", `rocksdb-js-${process.platform}-${process.arch}${runtime}`, "rocksdb-js.node");
71
- if ((0, node_fs.existsSync)(path)) return (0, node_path.resolve)(path);
71
+ return require.resolve(`@harperfast/rocksdb-js-${process.platform}-${process.arch}${runtime}`);
72
72
  } catch {}
73
73
  throw new Error("Unable to locate rocksdb-js native binding");
74
74
  }
75
- const binding = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)(locateBinding());
75
+ const binding = req(locateBinding());
76
76
  const config = binding.config;
77
77
  const constants = binding.constants;
78
78
  const NativeDatabase = binding.Database;
@@ -1079,10 +1079,15 @@ var Transaction = class extends DBI {
1079
1079
  * ```
1080
1080
  */
1081
1081
  var RocksDatabase = class RocksDatabase extends DBI {
1082
+ /**
1083
+ * The name of the database.
1084
+ */
1085
+ #name;
1082
1086
  constructor(pathOrStore, options) {
1083
1087
  if (typeof pathOrStore === "string") super(new Store(pathOrStore, options));
1084
1088
  else if (pathOrStore instanceof Store) super(pathOrStore);
1085
1089
  else throw new TypeError("Invalid database path or store");
1090
+ this.#name = options?.name ?? "default";
1086
1091
  }
1087
1092
  /**
1088
1093
  * Removes all data from the database asynchronously.
@@ -1281,6 +1286,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
1281
1286
  return this.store.listLogs();
1282
1287
  }
1283
1288
  /**
1289
+ * The name of the database.
1290
+ */
1291
+ get name() {
1292
+ return this.#name;
1293
+ }
1294
+ /**
1284
1295
  * Sugar method for opening a database.
1285
1296
  *
1286
1297
  * @param pathOrStore - The filesystem path to the database or a custom store.
@@ -1787,7 +1798,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
1787
1798
  //#region src/index.ts
1788
1799
  const versions = {
1789
1800
  rocksdb: version,
1790
- "rocksdb-js": "0.1.0"
1801
+ "rocksdb-js": "0.1.2"
1791
1802
  };
1792
1803
 
1793
1804
  //#endregion