@easy-cms/db-postgres 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 +12 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -127,9 +127,13 @@ function postgresJsConnection(url, options) {
|
|
|
127
127
|
async query(text2, params = []) {
|
|
128
128
|
return [...await client.unsafe(text2, [...params])];
|
|
129
129
|
},
|
|
130
|
-
async transaction(
|
|
130
|
+
async transaction(steps) {
|
|
131
131
|
await client.begin(async (tx) => {
|
|
132
|
-
|
|
132
|
+
const run = async (text2, params = []) => [...await tx.unsafe(text2, [...params])];
|
|
133
|
+
for (const step of steps) {
|
|
134
|
+
if (typeof step === "function") await step(run);
|
|
135
|
+
else await run(step.sql, step.params);
|
|
136
|
+
}
|
|
133
137
|
});
|
|
134
138
|
}
|
|
135
139
|
};
|
|
@@ -159,9 +163,13 @@ async function pgliteConnection(source, cwd) {
|
|
|
159
163
|
async query(text2, params = []) {
|
|
160
164
|
return (await pg.query(text2, [...params])).rows;
|
|
161
165
|
},
|
|
162
|
-
async transaction(
|
|
166
|
+
async transaction(steps) {
|
|
163
167
|
await pg.transaction(async (tx) => {
|
|
164
|
-
|
|
168
|
+
const run = async (text2, params = []) => (await tx.query(text2, [...params])).rows;
|
|
169
|
+
for (const step of steps) {
|
|
170
|
+
if (typeof step === "function") await step(run);
|
|
171
|
+
else await run(step.sql, step.params);
|
|
172
|
+
}
|
|
165
173
|
});
|
|
166
174
|
}
|
|
167
175
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/db-postgres",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.0",
|
|
4
4
|
"description": "PostgreSQL database adapter for Easy CMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"drizzle-kit": "0.31.11",
|
|
23
23
|
"drizzle-orm": "0.45.4",
|
|
24
24
|
"postgres": "^4.1.0",
|
|
25
|
-
"@easy-cms/drizzle": "^1.
|
|
25
|
+
"@easy-cms/drizzle": "^1.50.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@electric-sql/pglite": ">=0.3.0",
|
|
29
|
-
"@easy-cms/core": "^1.
|
|
29
|
+
"@easy-cms/core": "^1.50.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependenciesMeta": {
|
|
32
32
|
"@electric-sql/pglite": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@electric-sql/pglite": "^0.5.8",
|
|
38
|
-
"@easy-cms/core": "^1.
|
|
38
|
+
"@easy-cms/core": "^1.50.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|