@easy-cms/db-sqlite 1.49.0 → 1.50.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.js +21 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -95,8 +95,27 @@ function sqlite(options) {
|
|
|
95
95
|
const result = await client.execute({ sql: text2, args: [...params] });
|
|
96
96
|
return result.rows;
|
|
97
97
|
},
|
|
98
|
-
async transaction(
|
|
99
|
-
|
|
98
|
+
async transaction(steps) {
|
|
99
|
+
const statements = steps.filter((s) => typeof s !== "function");
|
|
100
|
+
if (statements.length === steps.length) {
|
|
101
|
+
await client.batch(statements.map(toStatement), "write");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const tx = await client.transaction("write");
|
|
105
|
+
try {
|
|
106
|
+
const run = async (text2, params = []) => (await tx.execute(toStatement({ sql: text2, params }))).rows;
|
|
107
|
+
for (const step of steps) {
|
|
108
|
+
if (typeof step === "function") await step(run);
|
|
109
|
+
else await run(step.sql, step.params);
|
|
110
|
+
}
|
|
111
|
+
await tx.commit();
|
|
112
|
+
} catch (error) {
|
|
113
|
+
await tx.rollback().catch(() => {
|
|
114
|
+
});
|
|
115
|
+
throw error;
|
|
116
|
+
} finally {
|
|
117
|
+
tx.close();
|
|
118
|
+
}
|
|
100
119
|
}
|
|
101
120
|
},
|
|
102
121
|
close: async () => client.close()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/db-sqlite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.0",
|
|
4
4
|
"description": "SQLite / libSQL database adapter for Easy CMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@libsql/client": "^0.18.0",
|
|
23
23
|
"drizzle-kit": "0.31.11",
|
|
24
24
|
"drizzle-orm": "0.45.4",
|
|
25
|
-
"@easy-cms/drizzle": "^1.
|
|
25
|
+
"@easy-cms/drizzle": "^1.50.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@easy-cms/core": "^1.
|
|
28
|
+
"@easy-cms/core": "^1.50.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"sharp": "^0.35.5",
|
|
32
|
-
"@easy-cms/core": "^1.
|
|
32
|
+
"@easy-cms/core": "^1.50.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|