@everystack/model 0.4.3 → 0.4.4
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/package.json +1 -1
- package/src/drizzle.ts +3 -0
- package/src/field.ts +7 -0
package/package.json
CHANGED
package/src/drizzle.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
date,
|
|
32
32
|
numeric,
|
|
33
33
|
varchar,
|
|
34
|
+
json,
|
|
34
35
|
jsonb,
|
|
35
36
|
primaryKey,
|
|
36
37
|
unique,
|
|
@@ -101,6 +102,8 @@ function baseColumn(columnName: string, spec: FieldSpec): PgColumnBuilderBase {
|
|
|
101
102
|
return spec.length !== undefined ? varchar(columnName, { length: spec.length }) : varchar(columnName);
|
|
102
103
|
case 'jsonb':
|
|
103
104
|
return jsonb(columnName);
|
|
105
|
+
case 'json':
|
|
106
|
+
return json(columnName);
|
|
104
107
|
case 'enum':
|
|
105
108
|
return getEnum(spec)(columnName);
|
|
106
109
|
default: {
|
package/src/field.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type FieldType =
|
|
|
28
28
|
| 'date'
|
|
29
29
|
| 'numeric'
|
|
30
30
|
| 'varchar'
|
|
31
|
+
| 'json'
|
|
31
32
|
| 'jsonb'
|
|
32
33
|
| 'enum';
|
|
33
34
|
|
|
@@ -242,7 +243,13 @@ export const field = {
|
|
|
242
243
|
numeric: (precision?: number, scale?: number): FieldBuilder => new FieldBuilder('numeric', { precision, scale }),
|
|
243
244
|
/** `varchar(length)` — length optional; `varchar()` is unbounded `character varying`. */
|
|
244
245
|
varchar: (length?: number): FieldBuilder => new FieldBuilder('varchar', { length }),
|
|
246
|
+
/** `jsonb` — binary JSON: normalized (keys sorted, dedup'd, whitespace stripped),
|
|
247
|
+
* GIN-indexable, faster operators. The right default for almost everything. */
|
|
245
248
|
jsonb: (): FieldBuilder => new FieldBuilder('jsonb'),
|
|
249
|
+
/** `json` — TEXT JSON: preserves key order, duplicate keys, and exact whitespace.
|
|
250
|
+
* Distinct from {@link jsonb}. Reach for it only when the literal input matters
|
|
251
|
+
* (order-sensitive payloads, round-tripping exact text); otherwise use `jsonb`. */
|
|
252
|
+
json: (): FieldBuilder => new FieldBuilder('json'),
|
|
246
253
|
/** A Postgres enum. The `name` is the `CREATE TYPE` name and is always explicit, so `db:pull` round-trips it. */
|
|
247
254
|
enum: (name: string, values: readonly string[]): FieldBuilder => new FieldBuilder('enum', { enumName: name, enumValues: values }),
|
|
248
255
|
} as const;
|