@wxn0brp/db-storage-sqlite 0.110.3 → 0.110.5-alpha.0

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
@@ -59,6 +59,9 @@ await db.users.update({ name: "John Doe" }, { email: "newemail@example.com" });
59
59
 
60
60
  // 8. Remove entries
61
61
  await db.users.remove({ name: "John Doe" });
62
+
63
+ // 9. Close the SQLite handle
64
+ await db.close();
62
65
  ```
63
66
 
64
67
  ## API Notes
package/dist/find.js CHANGED
@@ -4,10 +4,12 @@ import { toSqlValue } from "./index.js";
4
4
  export async function find(slv, config) {
5
5
  const { collection, search } = config;
6
6
  let sqlResult = [];
7
- const baseKeys = Object.keys(search)
8
- .filter(k => search[k] !== undefined)
9
- .filter(k => !k.startsWith("$"))
10
- .filter(k => typeof search[k] !== "object");
7
+ const baseKeys = typeof search === "object" && search !== null && !Array.isArray(search)
8
+ ? Object.keys(search)
9
+ .filter(k => search[k] !== undefined)
10
+ .filter(k => !k.startsWith("$"))
11
+ .filter(k => typeof search[k] !== "object")
12
+ : [];
11
13
  if (typeof search === "function" || baseKeys.length === 0) {
12
14
  const stmt = await slv._prepare(`SELECT * FROM ${collection}`);
13
15
  sqlResult = await Promise.resolve(stmt.all());
@@ -18,6 +20,8 @@ export async function find(slv, config) {
18
20
  const stmt = await slv._prepare(baseSql);
19
21
  sqlResult = await Promise.resolve(stmt.all(...baseValues));
20
22
  }
21
- const result = sqlResult.filter(entry => findObj(entry, search));
23
+ const result = sqlResult
24
+ .map(entry => findObj(config, entry))
25
+ .filter(Boolean);
22
26
  return findUtil(config, result, []);
23
27
  }
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare class SQLiteValthera extends ActionsBase {
9
9
  primaryKey: Record<string, string>;
10
10
  _inited: boolean;
11
11
  constructor(db: SupportedDB, primaryKey?: Record<string, string>);
12
+ close(): Promise<void>;
12
13
  _prepare(sql: string): Promise<VStatement>;
13
14
  getCollections(): Promise<string[]>;
14
15
  add(config: VQueryT.Add): Promise<Data>;
package/dist/index.js CHANGED
@@ -18,6 +18,11 @@ export class SQLiteValthera extends ActionsBase {
18
18
  this.db = db;
19
19
  this.primaryKey = primaryKey;
20
20
  }
21
+ async close() {
22
+ const close = this.db.close;
23
+ if (typeof close === "function")
24
+ await Promise.resolve(close.call(this.db));
25
+ }
21
26
  async _prepare(sql) {
22
27
  const db = this.db;
23
28
  if (typeof db.prepare !== "undefined")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-sqlite",
3
- "version": "0.110.3",
3
+ "version": "0.110.5-alpha.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "A pure SQLite storage adapter for the ValtheraDB database library",
@@ -22,14 +22,14 @@
22
22
  "@types/better-sqlite3": "^7.6.13",
23
23
  "@types/bun": "*",
24
24
  "@types/node": "*",
25
- "@wxn0brp/db-core": "^0.11.0-alpha.4",
26
- "better-sqlite3": "^12.9.0",
25
+ "@wxn0brp/db-core": "^0.11.1-alpha.2",
26
+ "better-sqlite3": "^12.10.0",
27
27
  "tsc-alias": "^1",
28
28
  "typescript": "^6"
29
29
  },
30
30
  "peerDependencies": {
31
- "@wxn0brp/db-core": "^0.11.0-alpha.4",
32
- "better-sqlite3": "^12.9.0"
31
+ "@wxn0brp/db-core": "^0.11.1-alpha.2",
32
+ "better-sqlite3": "^12.10.0"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@wxn0brp/db-core": {