@easy-cms/db-postgres 0.8.0 → 0.9.1
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 +19 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -45,10 +45,25 @@ var postgresDialect = {
|
|
|
45
45
|
});
|
|
46
46
|
return sql`exists (select 1 from jsonb_array_elements(${onlyArray(array)}) as ${el}(value)${where ? sql` where ${where}` : sql``})`;
|
|
47
47
|
},
|
|
48
|
-
firstElementValue: (array, path, type) => {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
48
|
+
firstElementValue: (array, lists, path, type) => {
|
|
49
|
+
const els = [alias()];
|
|
50
|
+
const from = [
|
|
51
|
+
sql`jsonb_array_elements(${onlyArray(array)}) with ordinality as ${els[0]}(value, idx)`
|
|
52
|
+
];
|
|
53
|
+
for (const list of lists) {
|
|
54
|
+
const outer = els.at(-1);
|
|
55
|
+
const el = alias();
|
|
56
|
+
els.push(el);
|
|
57
|
+
from.push(
|
|
58
|
+
sql`jsonb_array_elements(${onlyArray(sql`(${outer}.value #> ${jsonPath(list)})`)}) with ordinality as ${el}(value, idx)`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const text2 = sql`(${els.at(-1)}.value #>> ${jsonPath(path)})`;
|
|
62
|
+
const order = sql.join(
|
|
63
|
+
els.map((el) => sql`${el}.idx`),
|
|
64
|
+
sql`, `
|
|
65
|
+
);
|
|
66
|
+
return sql`(select ${cast(text2, type)} from ${sql.join(from, sql`, `)} where ${text2} is not null order by ${order} limit 1)`;
|
|
52
67
|
},
|
|
53
68
|
param: (n) => `$${n}`,
|
|
54
69
|
migrationsTableSQL: (name) => `CREATE TABLE IF NOT EXISTS "${name}" (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/db-postgres",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
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.3",
|
|
24
24
|
"postgres": "^3.4.9",
|
|
25
|
-
"@easy-cms/drizzle": "^0.
|
|
25
|
+
"@easy-cms/drizzle": "^0.9.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@electric-sql/pglite": ">=0.3.0",
|
|
29
|
-
"@easy-cms/core": "^0.
|
|
29
|
+
"@easy-cms/core": "^0.9.1"
|
|
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": "^0.
|
|
38
|
+
"@easy-cms/core": "^0.9.1"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|