@voltro/database 0.65.0 → 0.66.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/CHANGELOG.md +102 -0
- package/dist/{frameworkLiveTables-BURogL9N.js → frameworkLiveTables-CWbTSnjk.js} +34 -21
- package/dist/index.d.ts +114 -20
- package/dist/index.js +729 -623
- package/dist/sql.d.ts +21 -6
- package/dist/sql.js +783 -688
- package/package.json +2 -2
package/dist/sql.d.ts
CHANGED
|
@@ -402,6 +402,15 @@ declare interface ColumnDefinition<TsType, Type extends ColumnType = ColumnType,
|
|
|
402
402
|
readonly computed?: (row: Readonly<Record<string, unknown>>) => unknown;
|
|
403
403
|
readonly onUpdate?: 'now' | (() => unknown);
|
|
404
404
|
readonly references?: () => TableLike;
|
|
405
|
+
/**
|
|
406
|
+
* Physical/TypeScript representation of a foreign key. The default is
|
|
407
|
+
* `text`, matching Voltro's default TypeID primary key. `numeric` is for a
|
|
408
|
+
* target declared with `id({ scheme: 'numeric' })`; it renders as the
|
|
409
|
+
* dialect's 64-bit integer type and decodes as a JavaScript number.
|
|
410
|
+
*/
|
|
411
|
+
readonly referenceStorage?: 'text' | 'numeric';
|
|
412
|
+
/** Target key; defaults to the framework convention `id`. */
|
|
413
|
+
readonly referenceColumn?: string;
|
|
405
414
|
/**
|
|
406
415
|
* Cascade-on-delete behavior for a `reference()` column. Default
|
|
407
416
|
* `'restrict'` — Postgres / MySQL / MariaDB / MSSQL / SQLite all block
|
|
@@ -852,6 +861,8 @@ export declare interface ColumnSnapshot {
|
|
|
852
861
|
*/
|
|
853
862
|
readonly orphanPolicy?: 'fail' | 'null' | 'delete';
|
|
854
863
|
};
|
|
864
|
+
/** Physical representation for `reference()`; defaults to `text`. */
|
|
865
|
+
readonly referenceStorage?: 'text' | 'numeric';
|
|
855
866
|
/** `oneOf(['a','b'])` → CHECK constraint values. */
|
|
856
867
|
readonly oneOf?: ReadonlyArray<string>;
|
|
857
868
|
/**
|
|
@@ -1480,6 +1491,10 @@ export declare interface IndexSnapshot {
|
|
|
1480
1491
|
readonly table: string;
|
|
1481
1492
|
readonly columns: ReadonlyArray<string>;
|
|
1482
1493
|
readonly unique: boolean;
|
|
1494
|
+
/** SQL predicate for a partial/filtered index; never a full UNIQUE constraint. */
|
|
1495
|
+
readonly where?: string;
|
|
1496
|
+
/** False for an invalid PostgreSQL index left by an interrupted online build. */
|
|
1497
|
+
readonly valid?: boolean;
|
|
1483
1498
|
/**
|
|
1484
1499
|
* Expression / json-path index (`expressionIndex(...)` / `jsonIndex(...)`),
|
|
1485
1500
|
* i.e. at least one key is a SQL expression rather than a bare column. The
|
|
@@ -2927,8 +2942,8 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
|
|
|
2927
2942
|
*/
|
|
2928
2943
|
readonly previousTableName?: string;
|
|
2929
2944
|
/**
|
|
2930
|
-
*
|
|
2931
|
-
* When set it REPLACES the
|
|
2945
|
+
* Explicit PRIMARY KEY column set, declared via `.primaryKey(['key'])` or
|
|
2946
|
+
* `.primaryKey(['a','b'])`. When set it REPLACES the `id()` PK assumption: no column
|
|
2932
2947
|
* emits an inline `PRIMARY KEY`, and the table gets a table-level
|
|
2933
2948
|
* `PRIMARY KEY (a, b)` constraint instead. Empty (the default) means the
|
|
2934
2949
|
* `id()` column carries the PK inline, as before.
|
|
@@ -3237,12 +3252,12 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
|
|
|
3237
3252
|
weights?: Record<string, 'A' | 'B' | 'C' | 'D'>;
|
|
3238
3253
|
}) => Table<Name, Fields, Reactive, IxNames>;
|
|
3239
3254
|
/**
|
|
3240
|
-
* Declare
|
|
3255
|
+
* Declare an explicit PRIMARY KEY across one or more columns. Replaces the
|
|
3241
3256
|
* default single-column `id()` primary key: the listed columns become the
|
|
3242
3257
|
* table's PK, emitted as a table-level `PRIMARY KEY (a, b)` constraint on
|
|
3243
3258
|
* every dialect (no column carries an inline `PRIMARY KEY`).
|
|
3244
3259
|
*
|
|
3245
|
-
* Use for natural composite keys — a join table keyed on both its FKs, a
|
|
3260
|
+
* Use for a shared one-to-one FK key or natural composite keys — a join table keyed on both its FKs, a
|
|
3246
3261
|
* time-series table keyed on `(deviceId, ts)`, a per-tenant sequence keyed
|
|
3247
3262
|
* on `(tenantId, seq)`.
|
|
3248
3263
|
*
|
|
@@ -3255,12 +3270,12 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
|
|
|
3255
3270
|
* // → PRIMARY KEY ("userId", "orgId")
|
|
3256
3271
|
* ```
|
|
3257
3272
|
*
|
|
3258
|
-
* The columns are type-checked against the row.
|
|
3273
|
+
* The columns are type-checked against the row. An explicit PK implies
|
|
3259
3274
|
* NOT NULL on each member column (the DB enforces it). Don't also declare an
|
|
3260
3275
|
* `id()` column — the composite key is THE key; a stray `id()` would emit a
|
|
3261
3276
|
* second inline PK and the DDL would be rejected.
|
|
3262
3277
|
*/
|
|
3263
|
-
primaryKey: <const F extends readonly [keyof Fields & string,
|
|
3278
|
+
primaryKey: <const F extends readonly [keyof Fields & string, ...Array<keyof Fields & string>]>(fields: F) => Table<Name, Fields, Reactive, IxNames>;
|
|
3264
3279
|
/**
|
|
3265
3280
|
* Turn reactivity OFF for this table.
|
|
3266
3281
|
*
|