@holo-js/db-sqlite 0.1.9 → 0.2.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/dist/index.d.ts +7 -2
- package/dist/index.mjs +14 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { DriverAdapter, DriverQueryResult, DriverExecutionResult } from '@holo-js/db';
|
|
1
|
+
import { DriverAdapter, DriverQueryResult, DriverExecutionResult, DatabaseOperationOptions } from '@holo-js/db';
|
|
2
2
|
export { DriverAdapter, DriverExecutionResult, DriverQueryResult } from '@holo-js/db';
|
|
3
3
|
|
|
4
|
+
type SQLiteTransactionMode = 'deferred' | 'immediate' | 'exclusive';
|
|
5
|
+
type SQLiteTransactionOptions = DatabaseOperationOptions & {
|
|
6
|
+
readonly mode?: SQLiteTransactionMode;
|
|
7
|
+
};
|
|
4
8
|
interface SQLiteStatementLike {
|
|
5
9
|
all(...params: readonly unknown[]): Record<string, unknown>[];
|
|
6
10
|
run(...params: readonly unknown[]): {
|
|
@@ -32,7 +36,7 @@ declare class SQLiteAdapter implements DriverAdapter {
|
|
|
32
36
|
query<TRow extends Record<string, unknown> = Record<string, unknown>>(sql: string, bindings?: readonly unknown[]): Promise<DriverQueryResult<TRow>>;
|
|
33
37
|
introspect<TRow extends Record<string, unknown> = Record<string, unknown>>(sql: string, bindings?: readonly unknown[]): Promise<DriverQueryResult<TRow>>;
|
|
34
38
|
execute(sql: string, bindings?: readonly unknown[]): Promise<DriverExecutionResult>;
|
|
35
|
-
beginTransaction(): Promise<void>;
|
|
39
|
+
beginTransaction(options?: SQLiteTransactionOptions): Promise<void>;
|
|
36
40
|
commit(): Promise<void>;
|
|
37
41
|
rollback(): Promise<void>;
|
|
38
42
|
createSavepoint(name: string): Promise<void>;
|
|
@@ -40,6 +44,7 @@ declare class SQLiteAdapter implements DriverAdapter {
|
|
|
40
44
|
releaseSavepoint(name: string): Promise<void>;
|
|
41
45
|
private getDatabase;
|
|
42
46
|
private normalizeSavepointName;
|
|
47
|
+
private resolveBeginStatement;
|
|
43
48
|
}
|
|
44
49
|
declare function createSQLiteAdapter(options?: SQLiteAdapterOptions): SQLiteAdapter;
|
|
45
50
|
|
package/dist/index.mjs
CHANGED
|
@@ -73,8 +73,8 @@ var SQLiteAdapter = class {
|
|
|
73
73
|
lastInsertId: typeof result.lastInsertRowid === "bigint" ? Number(result.lastInsertRowid) : result.lastInsertRowid
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
async beginTransaction() {
|
|
77
|
-
this.getDatabase().exec(
|
|
76
|
+
async beginTransaction(options) {
|
|
77
|
+
this.getDatabase().exec(this.resolveBeginStatement(options?.mode));
|
|
78
78
|
}
|
|
79
79
|
async commit() {
|
|
80
80
|
this.getDatabase().exec("COMMIT");
|
|
@@ -104,6 +104,18 @@ var SQLiteAdapter = class {
|
|
|
104
104
|
}
|
|
105
105
|
return name;
|
|
106
106
|
}
|
|
107
|
+
resolveBeginStatement(mode = "deferred") {
|
|
108
|
+
if (mode === "deferred") {
|
|
109
|
+
return "BEGIN";
|
|
110
|
+
}
|
|
111
|
+
if (mode === "immediate") {
|
|
112
|
+
return "BEGIN IMMEDIATE";
|
|
113
|
+
}
|
|
114
|
+
if (mode === "exclusive") {
|
|
115
|
+
return "BEGIN EXCLUSIVE";
|
|
116
|
+
}
|
|
117
|
+
throw new TransactionError(`Unsupported SQLite transaction mode "${String(mode)}".`);
|
|
118
|
+
}
|
|
107
119
|
};
|
|
108
120
|
function createSQLiteAdapter(options = {}) {
|
|
109
121
|
return new SQLiteAdapter(options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/db-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Holo-JS Framework - SQLite database adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"test": "vitest --run"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@holo-js/db": "^0.
|
|
26
|
+
"@holo-js/db": "^0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"better-sqlite3": "^11.7.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@holo-js/db": "^0.
|
|
32
|
+
"@holo-js/db": "^0.2.0",
|
|
33
33
|
"@types/better-sqlite3": "^7.6.12",
|
|
34
34
|
"tsup": "^8.3.5",
|
|
35
35
|
"typescript": "^5.7.2",
|