@easy-cms/db-postgres 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +8 -0
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ import { drizzle as drizzlePostgresJs } from "drizzle-orm/postgres-js";
19
19
  import postgresJs from "postgres";
20
20
  import { DEFAULT_MIGRATION_DIR, DEFAULT_TABLE_PREFIX } from "@easy-cms/drizzle";
21
21
  var kit = () => import("drizzle-kit/api");
22
+ var PG_TYPES = { number: "double precision", integer: "integer", boolean: "boolean" };
22
23
  var postgresDialect = {
23
24
  name: "postgres",
24
25
  table: (name, columns, indexes) => pgTable(name, columns, indexes),
@@ -31,6 +32,13 @@ var postgresDialect = {
31
32
  boolean: (name) => boolean(name),
32
33
  json: (name) => jsonb(name),
33
34
  like: (column, pattern) => sql`${column} ILIKE ${pattern} ESCAPE '\\'`,
35
+ someElement: (column, condition) => {
36
+ const where = condition((path, type) => {
37
+ const text2 = sql`(_el.value #>> ${sql.raw(`'{${path.join(",")}}'`)})`;
38
+ return type === "text" ? text2 : sql`${text2}::${sql.raw(PG_TYPES[type])}`;
39
+ });
40
+ return sql`exists (select 1 from jsonb_array_elements(case when jsonb_typeof(${column}) = 'array' then ${column} end) as _el(value)${where ? sql` where ${where}` : sql``})`;
41
+ },
34
42
  param: (n) => `$${n}`,
35
43
  migrationsTableSQL: (name) => `CREATE TABLE IF NOT EXISTS "${name}" (
36
44
  "id" serial PRIMARY KEY NOT NULL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-cms/db-postgres",
3
- "version": "0.6.0",
3
+ "version": "0.7.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.3",
24
24
  "postgres": "^3.4.9",
25
- "@easy-cms/drizzle": "^0.6.0"
25
+ "@easy-cms/drizzle": "^0.7.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@electric-sql/pglite": ">=0.3.0",
29
- "@easy-cms/core": "^0.6.0"
29
+ "@easy-cms/core": "^0.7.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": "^0.6.0"
38
+ "@easy-cms/core": "^0.7.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"