pqb 0.71.3 → 0.72.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.d.ts +335 -356
- package/dist/index.js +190 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -182
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +8038 -8072
- package/dist/internal.js +6254 -0
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +6232 -7
- package/dist/internal.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -984,10 +984,15 @@ interface TableDataMethods<Key extends PropertyKey> {
|
|
|
984
984
|
* ```
|
|
985
985
|
*/
|
|
986
986
|
exclude(columns: TableData.Exclude.ColumnOrExpressionOptions<Key>[], options?: TableData.Exclude.Options): NonUniqDataItem;
|
|
987
|
-
foreignKey<Shape>(columns: [string, ...string[]], fnOrTable: () =>
|
|
988
|
-
columns
|
|
987
|
+
foreignKey<Shape>(columns: [string, ...string[]], fnOrTable: () => Column.ForeignKey.TableParam & {
|
|
988
|
+
columns?: {
|
|
989
989
|
shape: Shape;
|
|
990
990
|
};
|
|
991
|
+
instance?: () => {
|
|
992
|
+
columns: {
|
|
993
|
+
shape: Shape;
|
|
994
|
+
};
|
|
995
|
+
};
|
|
991
996
|
}, foreignColumns: [keyof Shape, ...(keyof Shape)[]], options?: TableData.References.Options): NonUniqDataItem;
|
|
992
997
|
foreignKey(columns: [string, ...string[]], fnOrTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options): NonUniqDataItem;
|
|
993
998
|
check(check: RawSqlBase, name?: string): NonUniqDataItem;
|
|
@@ -1059,6 +1064,8 @@ interface ColumnToCodeCtx {
|
|
|
1059
1064
|
currentSchema: string;
|
|
1060
1065
|
migration?: boolean;
|
|
1061
1066
|
snakeCase?: boolean;
|
|
1067
|
+
sql?: string;
|
|
1068
|
+
isSqlUsed?: boolean;
|
|
1062
1069
|
}
|
|
1063
1070
|
/**
|
|
1064
1071
|
* Push code: this will append a code string to the last code array element when possible.
|
|
@@ -1078,8 +1085,11 @@ declare const columnsShapeToCode: (ctx: ColumnToCodeCtx, shape: Column.Shape.Que
|
|
|
1078
1085
|
declare const pushTableDataCode: (code: Codes, ast: TableData) => Codes;
|
|
1079
1086
|
declare const primaryKeyInnerToCode: (primaryKey: TableData.PrimaryKey, t: string) => string;
|
|
1080
1087
|
declare const indexInnerToCode: (index: TableData.Index, t: string) => Codes;
|
|
1088
|
+
declare const indexToCode: (item: TableData.Index, t: string, prefix?: string) => Codes;
|
|
1081
1089
|
declare const excludeInnerToCode: (item: TableData.Exclude, t: string) => Codes;
|
|
1082
|
-
declare const
|
|
1090
|
+
declare const excludeToCode: (item: TableData.Exclude, t: string, prefix?: string) => Codes;
|
|
1091
|
+
declare const constraintToCode: (item: TableData.Constraint, t: string, m?: boolean, prefix?: string, ctx?: ColumnToCodeCtx) => Codes;
|
|
1092
|
+
declare const constraintInnerToCode: (item: TableData.Constraint, t: string, m?: boolean, ctx?: ColumnToCodeCtx) => Codes;
|
|
1083
1093
|
declare const referencesArgsToCode: ({
|
|
1084
1094
|
columns,
|
|
1085
1095
|
fnOrTable,
|
|
@@ -1140,21 +1150,21 @@ declare class SmallIntColumn<Schema extends ColumnSchemaConfig> extends IntegerB
|
|
|
1140
1150
|
querySchema: ReturnType<Schema['int']>;
|
|
1141
1151
|
constructor(schema: Schema);
|
|
1142
1152
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1143
|
-
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.
|
|
1153
|
+
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.HasDefault<T>;
|
|
1144
1154
|
}
|
|
1145
1155
|
declare class IntegerColumn<Schema extends ColumnSchemaConfig> extends IntegerBaseColumn<Schema> {
|
|
1146
1156
|
dataType: "int4";
|
|
1147
1157
|
querySchema: ReturnType<Schema['int']>;
|
|
1148
1158
|
constructor(schema: Schema);
|
|
1149
1159
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1150
|
-
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.
|
|
1160
|
+
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.HasDefault<T>;
|
|
1151
1161
|
}
|
|
1152
1162
|
declare class BigIntColumn<Schema extends ColumnSchemaConfig> extends NumberAsStringBaseColumn<Schema, string | number | bigint> {
|
|
1153
1163
|
dataType: "int8";
|
|
1154
1164
|
querySchema: ReturnType<Schema['stringSchema']>;
|
|
1155
1165
|
constructor(schema: Schema);
|
|
1156
1166
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1157
|
-
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.
|
|
1167
|
+
identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): Column.HasDefault<T>;
|
|
1158
1168
|
}
|
|
1159
1169
|
declare class RealColumn<Schema extends ColumnSchemaConfig> extends NumberBaseColumn<Schema, ReturnType<Schema['number']>> {
|
|
1160
1170
|
dataType: "float4";
|
|
@@ -1357,10 +1367,10 @@ declare class JSONTextColumn<T, Schema extends ColumnTypeSchemaArg, InputSchema
|
|
|
1357
1367
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1358
1368
|
}
|
|
1359
1369
|
interface DefaultSchemaConfig extends ColumnSchemaConfig<Column> {
|
|
1360
|
-
nullable<T extends Column.Pick.ForNullable>(this: T): Column.
|
|
1361
|
-
parse<T extends Column.Pick.ForParse, Output>(this: T, fn: (input: T['__type']) => Output): Column.
|
|
1362
|
-
parseNull<T extends Column.Pick.ForParseNull, Output>(this: T, fn: () => Output): Column.
|
|
1363
|
-
encode<T extends Column.Pick.Type, Input>(this: T, fn: (input: Input) => unknown): Column.
|
|
1370
|
+
nullable<T extends Column.Pick.ForNullable>(this: T): Column.Nullable<T>;
|
|
1371
|
+
parse<T extends Column.Pick.ForParse, Output>(this: T, fn: (input: T['__type']) => Output): Column.Parse<T, unknown, Output>;
|
|
1372
|
+
parseNull<T extends Column.Pick.ForParseNull, Output>(this: T, fn: () => Output): Column.ParseNull<T, unknown, Output>;
|
|
1373
|
+
encode<T extends Column.Pick.Type, Input>(this: T, fn: (input: Input) => unknown): Column.Encode<T, unknown, Input>;
|
|
1364
1374
|
/**
|
|
1365
1375
|
* @deprecated use narrowType instead
|
|
1366
1376
|
*/
|
|
@@ -1389,8 +1399,8 @@ interface DefaultSchemaConfig extends ColumnSchemaConfig<Column> {
|
|
|
1389
1399
|
__outputType: undefined extends Types['output'] ? T['__outputType'] : Types['output'];
|
|
1390
1400
|
__queryType: undefined extends Types['query'] ? T['__queryType'] : Types['query'];
|
|
1391
1401
|
}) => Types): { [K in keyof T]: K extends keyof Types ? Types[K] : T[K] };
|
|
1392
|
-
dateAsNumber<T extends Column.Pick.ForParse>(this: T): Column.
|
|
1393
|
-
dateAsDate<T extends Column.Pick.ForParse>(this: T): Column.
|
|
1402
|
+
dateAsNumber<T extends Column.Pick.ForParse>(this: T): Column.Parse<T, unknown, number>;
|
|
1403
|
+
dateAsDate<T extends Column.Pick.ForParse>(this: T): Column.Parse<T, unknown, Date>;
|
|
1394
1404
|
enum<const T extends readonly [string, ...string[]]>(dataType: string, type: T): EnumColumn<DefaultSchemaConfig, unknown, T>;
|
|
1395
1405
|
array<Item extends ArrayColumnValue>(item: Item): ArrayColumn<DefaultSchemaConfig, Item, unknown, unknown, unknown>;
|
|
1396
1406
|
json<T>(): JSONColumn<unknown extends T ? MaybeArray<string | number | boolean | object> : T, DefaultSchemaConfig>;
|
|
@@ -1721,7 +1731,7 @@ declare class TsVectorColumn<Schema extends ColumnSchemaConfig> extends Column {
|
|
|
1721
1731
|
*
|
|
1722
1732
|
* @param args
|
|
1723
1733
|
*/
|
|
1724
|
-
generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs | [language: string, columns: TsVectorGeneratedColumns] | [columns: TsVectorGeneratedColumns]): Column.
|
|
1734
|
+
generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs | [language: string, columns: TsVectorGeneratedColumns] | [columns: TsVectorGeneratedColumns]): Column.Generated<T>;
|
|
1725
1735
|
}
|
|
1726
1736
|
declare class TsQueryColumn<Schema extends ColumnSchemaConfig> extends Column {
|
|
1727
1737
|
__schema: Schema;
|
|
@@ -1808,8 +1818,8 @@ declare class BooleanColumn<Schema extends ColumnSchemaConfig> extends Column {
|
|
|
1808
1818
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1809
1819
|
}
|
|
1810
1820
|
interface Timestamps<T extends Column.Pick.Data> {
|
|
1811
|
-
createdAt: Column.
|
|
1812
|
-
updatedAt: Column.
|
|
1821
|
+
createdAt: Column.HasDefault<T>;
|
|
1822
|
+
updatedAt: Column.HasDefault<T>;
|
|
1813
1823
|
}
|
|
1814
1824
|
interface TimestampHelpers {
|
|
1815
1825
|
/**
|
|
@@ -1892,7 +1902,7 @@ interface DefaultColumnTypes<SchemaConfig extends ColumnSchemaConfig> extends Ti
|
|
|
1892
1902
|
decimal: SchemaConfig['decimal'];
|
|
1893
1903
|
real: SchemaConfig['real'];
|
|
1894
1904
|
doublePrecision: SchemaConfig['doublePrecision'];
|
|
1895
|
-
identity(options?: TableData.Identity): Column.
|
|
1905
|
+
identity(options?: TableData.Identity): Column.HasDefault<ReturnType<SchemaConfig['integer']>>;
|
|
1896
1906
|
smallSerial: SchemaConfig['smallSerial'];
|
|
1897
1907
|
serial: SchemaConfig['serial'];
|
|
1898
1908
|
bigSerial: SchemaConfig['bigSerial'];
|
|
@@ -2055,8 +2065,8 @@ type JoinResultRequireMain<T extends PickQuerySelectable, JoinedSelectable> = {
|
|
|
2055
2065
|
*/
|
|
2056
2066
|
type JoinResult<T extends PickQuerySelectableRelationsResultReturnType, Joined extends PickQuerySelectableRelations, RequireMain> = RequireMain extends true ? { [K in keyof T]: K extends '__selectable' ? T['__selectable'] & Joined['__selectable'] : K extends 'relations' ? { [K in keyof T['relations'] | keyof Joined['relations']]: K extends keyof Joined['relations'] ? Joined['relations'][K] : T['relations'][K] } : T[K] } : { [K in keyof T]: K extends '__selectable' ? { [K in keyof T['__selectable']]: {
|
|
2057
2067
|
as: T['__selectable'][K]['as'];
|
|
2058
|
-
column: Column.
|
|
2059
|
-
} } & Joined['__selectable'] : K extends 'result' ? { [K in keyof T['result']]: Column.
|
|
2068
|
+
column: Column.QueryColumnToNullable<T['__selectable'][K]['column']>;
|
|
2069
|
+
} } & Joined['__selectable'] : K extends 'result' ? { [K in keyof T['result']]: Column.QueryColumnToNullable<T['result'][K]> } : K extends 'then' ? QueryThenByQuery<T, { [K in keyof T['result']]: Column.QueryColumnToNullable<T['result'][K]> }> : K extends 'relations' ? { [K in keyof T['relations'] | keyof Joined['relations']]: K extends keyof Joined['relations'] ? Joined['relations'][K] : T['relations'][K] } : T[K] };
|
|
2060
2070
|
/**
|
|
2061
2071
|
* Calls {@link JoinResult} with either callback result, if join has a callback,
|
|
2062
2072
|
* or with a query derived from the first join argument.
|
|
@@ -2103,7 +2113,7 @@ type JoinResultSelectable<Result extends Column.QueryColumns, As extends string,
|
|
|
2103
2113
|
column: ColumnsShape.MapToNullableObjectColumn<Result>;
|
|
2104
2114
|
} : {
|
|
2105
2115
|
as: K;
|
|
2106
|
-
column: Column.
|
|
2116
|
+
column: Column.QueryColumnToNullable<Result[K]>;
|
|
2107
2117
|
} };
|
|
2108
2118
|
relations: { [K in keyof JoinedRelations & string as `${As}.${K}`]: JoinedRelations[K] };
|
|
2109
2119
|
};
|
|
@@ -2199,36 +2209,21 @@ declare class QueryJoin {
|
|
|
2199
2209
|
* For the following examples, imagine you have a `User` table with `id` and `name`, and `Message` table with `id`, `text`, messages belongs to user via `userId` column:
|
|
2200
2210
|
*
|
|
2201
2211
|
* ```ts
|
|
2202
|
-
* export
|
|
2203
|
-
*
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
*
|
|
2207
|
-
*
|
|
2208
|
-
*
|
|
2209
|
-
* relations = {
|
|
2210
|
-
* messages: this.hasMany(() => MessageTable, {
|
|
2211
|
-
* primaryKey: 'id',
|
|
2212
|
-
* foreignKey: 'userId',
|
|
2213
|
-
* }),
|
|
2214
|
-
* };
|
|
2215
|
-
* }
|
|
2216
|
-
*
|
|
2217
|
-
* export class MessageTable extends BaseTable {
|
|
2218
|
-
* readonly table = 'message';
|
|
2219
|
-
* columns = this.setColumns((t) => ({
|
|
2220
|
-
* id: t.identity().primaryKey(),
|
|
2221
|
-
* text: t.text(),
|
|
2222
|
-
* ...t.timestamps(),
|
|
2223
|
-
* }));
|
|
2212
|
+
* export const UserTable = defineTable('user', (t) => ({
|
|
2213
|
+
* id: t.identity().primaryKey(),
|
|
2214
|
+
* name: t.text(),
|
|
2215
|
+
* })).relations((user) => ({
|
|
2216
|
+
* messages: user('id').hasMany(() => MessageTable('userId')),
|
|
2217
|
+
* }));
|
|
2224
2218
|
*
|
|
2225
|
-
*
|
|
2226
|
-
*
|
|
2227
|
-
*
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2231
|
-
*
|
|
2219
|
+
* export const MessageTable = defineTable('message', (t) => ({
|
|
2220
|
+
* id: t.identity().primaryKey(),
|
|
2221
|
+
* userId: t.integer(),
|
|
2222
|
+
* text: t.text(),
|
|
2223
|
+
* ...t.timestamps(),
|
|
2224
|
+
* })).relations((message) => ({
|
|
2225
|
+
* user: message('userId').belongsTo(() => UserTable('id')),
|
|
2226
|
+
* }));
|
|
2232
2227
|
* ```
|
|
2233
2228
|
*
|
|
2234
2229
|
* `join` is a method for SQL `JOIN`, which is equivalent to `INNER JOIN`, `LEFT INNERT JOIN`.
|
|
@@ -2425,7 +2420,7 @@ declare class QueryJoin {
|
|
|
2425
2420
|
* ```ts
|
|
2426
2421
|
* db.user.join(
|
|
2427
2422
|
* db.message,
|
|
2428
|
-
* // `sql` can be imported from your
|
|
2423
|
+
* // `sql` can be imported from your table factory file
|
|
2429
2424
|
* sql`lower("message"."text") = lower("user"."name")`,
|
|
2430
2425
|
* );
|
|
2431
2426
|
* ```
|
|
@@ -3110,12 +3105,12 @@ declare class SearchMethods {
|
|
|
3110
3105
|
*
|
|
3111
3106
|
* By default, the search language is English.
|
|
3112
3107
|
*
|
|
3113
|
-
* You can set a different default language in the `
|
|
3108
|
+
* You can set a different default language in the `createTableFactory` config:
|
|
3114
3109
|
*
|
|
3115
3110
|
* ```ts
|
|
3116
|
-
* import {
|
|
3111
|
+
* import { createTableFactory } from 'orchid-orm';
|
|
3117
3112
|
*
|
|
3118
|
-
* export const
|
|
3113
|
+
* export const { defineTable, defineView, sql } = createTableFactory({
|
|
3119
3114
|
* language: 'swedish',
|
|
3120
3115
|
* });
|
|
3121
3116
|
* ```
|
|
@@ -3900,7 +3895,7 @@ declare class Where {
|
|
|
3900
3895
|
* Constructing `WHERE` conditions:
|
|
3901
3896
|
*
|
|
3902
3897
|
* ```ts
|
|
3903
|
-
* import { sql } from './
|
|
3898
|
+
* import { sql } from './table-factory';
|
|
3904
3899
|
*
|
|
3905
3900
|
* db.table.where({
|
|
3906
3901
|
* // column of the current table
|
|
@@ -3916,7 +3911,7 @@ declare class Where {
|
|
|
3916
3911
|
* },
|
|
3917
3912
|
*
|
|
3918
3913
|
* // where column equals to raw SQL
|
|
3919
|
-
* // import `sql` from your
|
|
3914
|
+
* // import `sql` from your table factory
|
|
3920
3915
|
* column: sql`sql expression`,
|
|
3921
3916
|
* // or use `(q) => sql` for the same
|
|
3922
3917
|
* column2: (q) => sql`sql expression`,
|
|
@@ -4526,21 +4521,16 @@ interface ScopeArgumentQuery<Table extends string | undefined, Shape extends Col
|
|
|
4526
4521
|
* If you define a scope with name `default`, it will be applied for all table queries by default.
|
|
4527
4522
|
*
|
|
4528
4523
|
* ```ts
|
|
4529
|
-
* import {
|
|
4530
|
-
*
|
|
4531
|
-
* export class SomeTable extends BaseTable {
|
|
4532
|
-
* readonly table = 'some';
|
|
4533
|
-
* columns = this.setColumns((t) => ({
|
|
4534
|
-
* id: t.identity().primaryKey(),
|
|
4535
|
-
* hidden: t.boolean(),
|
|
4536
|
-
* active: t.boolean(),
|
|
4537
|
-
* }));
|
|
4524
|
+
* import { defineTable } from './table-factory';
|
|
4538
4525
|
*
|
|
4539
|
-
*
|
|
4540
|
-
*
|
|
4541
|
-
*
|
|
4542
|
-
*
|
|
4543
|
-
* }
|
|
4526
|
+
* export const SomeTable = defineTable('some', (t) => ({
|
|
4527
|
+
* id: t.identity().primaryKey(),
|
|
4528
|
+
* hidden: t.boolean(),
|
|
4529
|
+
* active: t.boolean(),
|
|
4530
|
+
* })).scopes({
|
|
4531
|
+
* default: (q) => q.where({ hidden: false }),
|
|
4532
|
+
* active: (q) => q.where({ active: true }),
|
|
4533
|
+
* });
|
|
4544
4534
|
*
|
|
4545
4535
|
* const db = orchidORM(
|
|
4546
4536
|
* { databaseURL: '...' },
|
|
@@ -4660,20 +4650,20 @@ interface NonDeletedScope {
|
|
|
4660
4650
|
* All queries on such table will filter out deleted records by default.
|
|
4661
4651
|
*
|
|
4662
4652
|
* ```ts
|
|
4663
|
-
* import {
|
|
4664
|
-
*
|
|
4665
|
-
* export class SomeTable extends BaseTable {
|
|
4666
|
-
* readonly table = 'some';
|
|
4667
|
-
* columns = this.setColumns((t) => ({
|
|
4668
|
-
* id: t.identity().primaryKey(),
|
|
4669
|
-
* deletedAt: t.timestamp().nullable(),
|
|
4670
|
-
* }));
|
|
4653
|
+
* import { defineTable } from './table-factory';
|
|
4671
4654
|
*
|
|
4655
|
+
* export const SomeTable = defineTable('some', (t) => ({
|
|
4656
|
+
* id: t.identity().primaryKey(),
|
|
4657
|
+
* deletedAt: t.timestamp().nullable(),
|
|
4658
|
+
* }))
|
|
4672
4659
|
* // true is for using `deletedAt` column
|
|
4673
|
-
*
|
|
4674
|
-
*
|
|
4675
|
-
*
|
|
4676
|
-
*
|
|
4660
|
+
* .softDelete();
|
|
4661
|
+
*
|
|
4662
|
+
* // or provide a different column name
|
|
4663
|
+
* export const OtherTable = defineTable('other', (t) => ({
|
|
4664
|
+
* id: t.identity().primaryKey(),
|
|
4665
|
+
* myDeletedAt: t.timestamp().nullable(),
|
|
4666
|
+
* })).softDelete('myDeletedAt');
|
|
4677
4667
|
*
|
|
4678
4668
|
* const db = orchidORM(
|
|
4679
4669
|
* { databaseURL: '...' },
|
|
@@ -4733,9 +4723,11 @@ declare namespace RlsPolicy {
|
|
|
4733
4723
|
export {};
|
|
4734
4724
|
}
|
|
4735
4725
|
declare namespace Rls {
|
|
4736
|
-
interface
|
|
4726
|
+
interface TableConfigBase {
|
|
4737
4727
|
enable?: boolean;
|
|
4738
4728
|
force?: boolean;
|
|
4729
|
+
}
|
|
4730
|
+
interface TableConfig extends TableConfigBase {
|
|
4739
4731
|
permit: [RlsPolicy.Policy, ...RlsPolicy.Policy[]];
|
|
4740
4732
|
restrict?: RlsPolicy.Policy[];
|
|
4741
4733
|
}
|
|
@@ -5379,7 +5371,12 @@ declare class RawSql<T extends Column.Pick.QueryColumn = Column.Pick.QueryColumn
|
|
|
5379
5371
|
makeSQL(ctx: ToSqlValues, quotedAs?: string): string;
|
|
5380
5372
|
}
|
|
5381
5373
|
declare const isRawSQL: (arg: unknown) => arg is RawSqlBase;
|
|
5382
|
-
|
|
5374
|
+
interface RawSqlToCodeCtx {
|
|
5375
|
+
t: string;
|
|
5376
|
+
sql?: string;
|
|
5377
|
+
isSqlUsed?: boolean;
|
|
5378
|
+
}
|
|
5379
|
+
declare const rawSqlToCode: (rawSql: RawSqlBase, ctx: string | RawSqlToCodeCtx) => string;
|
|
5383
5380
|
interface DynamicRawSQL<T extends Column.Pick.QueryColumn> extends Expression<T>, ExpressionTypeMethod {}
|
|
5384
5381
|
declare class DynamicRawSQL<T extends Column.Pick.QueryColumn, ColumnTypes = DefaultColumnTypes<ColumnSchemaConfig>> extends Expression<T> {
|
|
5385
5382
|
fn: DynamicSQLArg<T>;
|
|
@@ -5501,14 +5498,14 @@ declare const rawSqlToSql: (sql: string | RawSqlBase) => SingleSql;
|
|
|
5501
5498
|
declare const sqlToRawSql: (sql: SingleSql) => RawSqlBase;
|
|
5502
5499
|
declare class QuerySql<ColumnTypes> {
|
|
5503
5500
|
/**
|
|
5504
|
-
* @deprecated: use `sql` exported from the
|
|
5501
|
+
* @deprecated: use `sql` exported from the table factory file.
|
|
5505
5502
|
*
|
|
5506
|
-
* When there is a need to use a piece of raw SQL, use the `sql` exported from the
|
|
5503
|
+
* When there is a need to use a piece of raw SQL, use the `sql` exported from the table factory file, it is also attached to query objects for convenience.
|
|
5507
5504
|
*
|
|
5508
5505
|
* When selecting a custom SQL, specify a resulting type with `<generic>` syntax:
|
|
5509
5506
|
*
|
|
5510
5507
|
* ```ts
|
|
5511
|
-
* import { sql } from './
|
|
5508
|
+
* import { sql } from './table-factory';
|
|
5512
5509
|
*
|
|
5513
5510
|
* const result: { num: number }[] = await db.table.select({
|
|
5514
5511
|
* num: sql<number>`random() * 100`,
|
|
@@ -5520,7 +5517,7 @@ declare class QuerySql<ColumnTypes> {
|
|
|
5520
5517
|
* This example assumes that the `timestamp` column was overridden with `asDate` as shown in [Override column types](/guide/columns-overview#override-column-types).
|
|
5521
5518
|
*
|
|
5522
5519
|
* ```ts
|
|
5523
|
-
* import { sql } from './
|
|
5520
|
+
* import { sql } from './table-factory';
|
|
5524
5521
|
*
|
|
5525
5522
|
* const result: { timestamp: Date }[] = await db.table.select({
|
|
5526
5523
|
* timestamp: sql`now()`.type((t) => t.timestamp()),
|
|
@@ -6297,24 +6294,19 @@ type AfterCommitErrorResult = AfterCommitErrorFulfilledResult | AfterCommitError
|
|
|
6297
6294
|
* so later they can be identified when handling after commit errors.
|
|
6298
6295
|
*
|
|
6299
6296
|
* ```ts
|
|
6300
|
-
*
|
|
6301
|
-
*
|
|
6302
|
-
*
|
|
6303
|
-
*
|
|
6304
|
-
*
|
|
6305
|
-
*
|
|
6306
|
-
*
|
|
6307
|
-
* // anonymous funciton - has no name
|
|
6308
|
-
* this.afterCreateCommit([], async () => {
|
|
6309
|
-
* // ...
|
|
6310
|
-
* });
|
|
6297
|
+
* export const SomeTable = defineTable('someTable', (t) => ({
|
|
6298
|
+
* ...someColumns,
|
|
6299
|
+
* })).init((orm: typeof db, hooks) => {
|
|
6300
|
+
* // anonymous funciton - has no name
|
|
6301
|
+
* hooks.afterCreateCommit([], async () => {
|
|
6302
|
+
* // ...
|
|
6303
|
+
* });
|
|
6311
6304
|
*
|
|
6312
|
-
*
|
|
6313
|
-
*
|
|
6314
|
-
*
|
|
6315
|
-
*
|
|
6316
|
-
*
|
|
6317
|
-
* }
|
|
6305
|
+
* // named function
|
|
6306
|
+
* hooks.afterCreateCommit([], function myHook() {
|
|
6307
|
+
* // ...
|
|
6308
|
+
* });
|
|
6309
|
+
* });
|
|
6318
6310
|
* ```
|
|
6319
6311
|
*/
|
|
6320
6312
|
declare class AfterCommitError extends OrchidOrmError {
|
|
@@ -6716,45 +6708,42 @@ interface SelectSqlCallback {
|
|
|
6716
6708
|
}
|
|
6717
6709
|
type SelectSqlColumn<T extends Column.Pick.DataAndDataType, Expr extends Expression> = unknown extends Expr['result']['value']['__outputType'] ? T : { [K in keyof T]: K extends '__outputType' ? Expr['result']['value']['__outputType'] : T[K] };
|
|
6718
6710
|
declare namespace Column {
|
|
6719
|
-
export
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6711
|
+
export interface IsPrimaryKey<Name extends string> {
|
|
6712
|
+
data: {
|
|
6713
|
+
primaryKey: Name;
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
export type IsUnique<Name extends string> = {
|
|
6717
|
+
data: {
|
|
6718
|
+
unique: Name;
|
|
6719
|
+
};
|
|
6720
|
+
};
|
|
6721
|
+
export type Nullable<T extends Column.Pick.ForNullable> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends '__queryType' ? T['__queryType'] | null : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
|
|
6722
|
+
export type NullableWithSchema<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
|
|
6723
|
+
export type QueryColumnToNullable<C> = { [K in keyof C]: K extends '__outputType' | '__queryType' ? C[K] | null : C[K] };
|
|
6724
|
+
export type QueryColumnToOptional<C> = { [K in keyof C]: K extends '__outputType' ? C[K] | undefined : C[K] };
|
|
6725
|
+
interface DataNullable {
|
|
6726
|
+
isNullable: true;
|
|
6727
|
+
optional: true;
|
|
6728
|
+
}
|
|
6729
|
+
export interface OperatorsNullable<Column extends Column.Pick.QueryColumn> {
|
|
6730
|
+
equals: Operator<Column['__queryType'] | null, Column>;
|
|
6731
|
+
not: Operator<Column['__queryType'] | null, Column>;
|
|
6732
|
+
isDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6733
|
+
isNotDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6734
|
+
}
|
|
6735
|
+
export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends '__inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
|
|
6736
|
+
export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? (Output extends null ? never : Output) | (unknown extends T['__nullType'] ? null : T['__nullType']) : Output : K extends 'outputSchema' ? null extends T['__type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
|
|
6737
|
+
export type ParseNull<T extends Column.Pick.ForParseNull, NullSchema, NullType> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? Exclude<T['__outputType'], null> | NullType : T['__outputType'] : K extends '__nullType' ? NullType : K extends 'outputSchema' ? null extends T['__type'] ? T['outputSchema'] | NullSchema : T['outputSchema'] : K extends 'nullSchema' ? NullSchema : T[K] };
|
|
6738
|
+
export type HasDefault<T extends Column.Pick.Data> = T & Column.Data.Default;
|
|
6739
|
+
type DefaultSelectData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'explicitSelect' ? Value extends true ? false : true : T[K] };
|
|
6740
|
+
export type DefaultSelect<T extends Column.Pick.Data, Value extends boolean> = { [K in keyof T]: K extends 'data' ? DefaultSelectData<T['data'], Value> : T[K] };
|
|
6741
|
+
export interface IsAppReadOnly {
|
|
6742
|
+
data: {
|
|
6743
|
+
appReadOnly: true;
|
|
6729
6744
|
};
|
|
6730
|
-
export type Nullable<T extends Column.Pick.ForNullable> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends '__queryType' ? T['__queryType'] | null : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
|
|
6731
|
-
export type NullableWithSchema<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
|
|
6732
|
-
export type QueryColumnToNullable<C> = { [K in keyof C]: K extends '__outputType' | '__queryType' ? C[K] | null : C[K] };
|
|
6733
|
-
export type QueryColumnToOptional<C> = { [K in keyof C]: K extends '__outputType' ? C[K] | undefined : C[K] };
|
|
6734
|
-
interface DataNullable {
|
|
6735
|
-
isNullable: true;
|
|
6736
|
-
optional: true;
|
|
6737
|
-
}
|
|
6738
|
-
export interface OperatorsNullable<Column extends Column.Pick.QueryColumn> {
|
|
6739
|
-
equals: Operator<Column['__queryType'] | null, Column>;
|
|
6740
|
-
not: Operator<Column['__queryType'] | null, Column>;
|
|
6741
|
-
isDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6742
|
-
isNotDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6743
|
-
}
|
|
6744
|
-
export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends '__inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
|
|
6745
|
-
export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? (Output extends null ? never : Output) | (unknown extends T['__nullType'] ? null : T['__nullType']) : Output : K extends 'outputSchema' ? null extends T['__type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
|
|
6746
|
-
export type ParseNull<T extends Column.Pick.ForParseNull, NullSchema, NullType> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? Exclude<T['__outputType'], null> | NullType : T['__outputType'] : K extends '__nullType' ? NullType : K extends 'outputSchema' ? null extends T['__type'] ? T['outputSchema'] | NullSchema : T['outputSchema'] : K extends 'nullSchema' ? NullSchema : T[K] };
|
|
6747
|
-
export type HasDefault<T extends Column.Pick.Data> = T & Column.Data.Default;
|
|
6748
|
-
type DefaultSelectData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'explicitSelect' ? Value extends true ? false : true : T[K] };
|
|
6749
|
-
export type DefaultSelect<T extends Column.Pick.Data, Value extends boolean> = { [K in keyof T]: K extends 'data' ? DefaultSelectData<T['data'], Value> : T[K] };
|
|
6750
|
-
export interface IsAppReadOnly {
|
|
6751
|
-
data: {
|
|
6752
|
-
appReadOnly: true;
|
|
6753
|
-
};
|
|
6754
|
-
}
|
|
6755
|
-
export type Generated<T extends Column.Pick.Data> = { [K in keyof T]: K extends 'data' ? { [K in keyof T['data']]: K extends 'default' ? true : T['data'][K] } : K extends '__inputType' ? never : T[K] };
|
|
6756
|
-
export {};
|
|
6757
6745
|
}
|
|
6746
|
+
export type Generated<T extends Column.Pick.Data> = { [K in keyof T]: K extends 'data' ? { [K in keyof T['data']]: K extends 'default' ? true : T['data'][K] } : K extends '__inputType' ? never : T[K] };
|
|
6758
6747
|
export namespace Pick {
|
|
6759
6748
|
interface Data {
|
|
6760
6749
|
data: Column.Data;
|
|
@@ -6845,12 +6834,39 @@ declare namespace Column {
|
|
|
6845
6834
|
schema?: string;
|
|
6846
6835
|
table: string;
|
|
6847
6836
|
nameInDb?: string;
|
|
6848
|
-
columns:
|
|
6837
|
+
columns: {
|
|
6838
|
+
shape: unknown;
|
|
6839
|
+
};
|
|
6840
|
+
}
|
|
6841
|
+
interface TableParamInstanceInput {
|
|
6842
|
+
schema?: QuerySchema;
|
|
6843
|
+
table?: string;
|
|
6844
|
+
nameInDb?: string;
|
|
6845
|
+
columns: {
|
|
6846
|
+
shape: unknown;
|
|
6847
|
+
};
|
|
6849
6848
|
}
|
|
6850
|
-
interface
|
|
6851
|
-
|
|
6849
|
+
interface TableParamWithInstance {
|
|
6850
|
+
instance(): TableParamInstanceInput;
|
|
6851
|
+
}
|
|
6852
|
+
interface TableParamWithData {
|
|
6853
|
+
data: {
|
|
6854
|
+
columns: unknown;
|
|
6855
|
+
};
|
|
6856
|
+
instance(): TableParamInstanceInput;
|
|
6852
6857
|
}
|
|
6853
|
-
type
|
|
6858
|
+
type TableParam = (new () => TableParamInstance) | TableParamWithInstance | TableParamWithData;
|
|
6859
|
+
type ColumnNameOfTable<Table extends Column.ForeignKey.TableParam> = Table extends {
|
|
6860
|
+
data: {
|
|
6861
|
+
columns: infer R;
|
|
6862
|
+
};
|
|
6863
|
+
} ? keyof R : Table extends {
|
|
6864
|
+
instance(): {
|
|
6865
|
+
columns: {
|
|
6866
|
+
shape: infer R;
|
|
6867
|
+
};
|
|
6868
|
+
};
|
|
6869
|
+
} ? keyof R : Table extends (new () => {
|
|
6854
6870
|
columns: {
|
|
6855
6871
|
shape: infer R;
|
|
6856
6872
|
};
|
|
@@ -6968,7 +6984,7 @@ declare namespace Column {
|
|
|
6968
6984
|
export type AsTypeArg<Schema> = AsTypeArgWithType<Schema> | AsTypeArgWithoutType<Schema>;
|
|
6969
6985
|
export {};
|
|
6970
6986
|
}
|
|
6971
|
-
declare function makeColumnNullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema>(column: T, inputSchema: InputSchema, outputSchema: OutputSchema, querySchema: QuerySchema): Column.
|
|
6987
|
+
declare function makeColumnNullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema>(column: T, inputSchema: InputSchema, outputSchema: OutputSchema, querySchema: QuerySchema): Column.NullableWithSchema<T, InputSchema, OutputSchema, QuerySchema>;
|
|
6972
6988
|
declare const setColumnData: <T extends Column.Pick.Data, K extends keyof T["data"]>(q: T, key: K, value: T["data"][K]) => T;
|
|
6973
6989
|
declare const setDataValue: <T extends Column.Pick.Data, Key extends string, Value>(item: T, key: Key, value: Value, params?: Column.Error.StringOrMessage) => T;
|
|
6974
6990
|
declare function setCurrentColumnName(name: string): void;
|
|
@@ -7000,31 +7016,28 @@ declare abstract class Column {
|
|
|
7000
7016
|
* Or you can specify a callback that returns a value. This function will be called for each creating record. Such a default won't be applied to a database.
|
|
7001
7017
|
*
|
|
7002
7018
|
* ```ts
|
|
7003
|
-
* export
|
|
7004
|
-
*
|
|
7005
|
-
*
|
|
7006
|
-
*
|
|
7007
|
-
* int: t.integer().default(123),
|
|
7008
|
-
* text: t.text().default('text'),
|
|
7019
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7020
|
+
* // values as defaults:
|
|
7021
|
+
* int: t.integer().default(123),
|
|
7022
|
+
* text: t.text().default('text'),
|
|
7009
7023
|
*
|
|
7010
|
-
*
|
|
7011
|
-
*
|
|
7024
|
+
* // raw SQL default:
|
|
7025
|
+
* timestamp: t.timestamp().default(t.sql`now()`),
|
|
7012
7026
|
*
|
|
7013
|
-
*
|
|
7014
|
-
*
|
|
7015
|
-
*
|
|
7016
|
-
* }
|
|
7027
|
+
* // runtime default, each new records gets a new random value:
|
|
7028
|
+
* random: t.numeric().default(() => Math.random()),
|
|
7029
|
+
* }));
|
|
7017
7030
|
* ```
|
|
7018
7031
|
*
|
|
7019
7032
|
* @param value - default value or a function returning a value
|
|
7020
7033
|
*/
|
|
7021
|
-
default<T extends Column.Pick.DataAndInputType, Value extends T['__inputType'] | null | RawSqlBase | (() => T['__inputType'])>(this: T, value: Value): Column.
|
|
7034
|
+
default<T extends Column.Pick.DataAndInputType, Value extends T['__inputType'] | null | RawSqlBase | (() => T['__inputType'])>(this: T, value: Value): Column.HasDefault<T>;
|
|
7022
7035
|
/**
|
|
7023
7036
|
* Use `hasDefault` to let the column be omitted when creating records.
|
|
7024
7037
|
*
|
|
7025
7038
|
* It's better to use {@link default} instead so the value is explicit and serves as a hint.
|
|
7026
7039
|
*/
|
|
7027
|
-
hasDefault<T extends Column.Pick.Data>(this: T): Column.
|
|
7040
|
+
hasDefault<T extends Column.Pick.Data>(this: T): Column.HasDefault<T>;
|
|
7028
7041
|
/**
|
|
7029
7042
|
* Set a database-level validation check to a column. `check` accepts a raw SQL.
|
|
7030
7043
|
*
|
|
@@ -7056,12 +7069,9 @@ declare abstract class Column {
|
|
|
7056
7069
|
* Nullable columns are optional when creating records.
|
|
7057
7070
|
*
|
|
7058
7071
|
* ```ts
|
|
7059
|
-
* export
|
|
7060
|
-
*
|
|
7061
|
-
*
|
|
7062
|
-
* name: t.integer().nullable(),
|
|
7063
|
-
* }));
|
|
7064
|
-
* }
|
|
7072
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7073
|
+
* name: t.integer().nullable(),
|
|
7074
|
+
* }));
|
|
7065
7075
|
* ```
|
|
7066
7076
|
*/
|
|
7067
7077
|
nullable: this['__schema']['nullable'];
|
|
@@ -7076,21 +7086,18 @@ declare abstract class Column {
|
|
|
7076
7086
|
* ```ts
|
|
7077
7087
|
* import { z } from 'zod';
|
|
7078
7088
|
*
|
|
7079
|
-
* export
|
|
7080
|
-
*
|
|
7081
|
-
*
|
|
7082
|
-
*
|
|
7083
|
-
*
|
|
7084
|
-
*
|
|
7085
|
-
*
|
|
7086
|
-
*
|
|
7087
|
-
*
|
|
7088
|
-
*
|
|
7089
|
-
*
|
|
7090
|
-
*
|
|
7091
|
-
* .encode((input: boolean | number | string) => String(input)),
|
|
7092
|
-
* }));
|
|
7093
|
-
* }
|
|
7089
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7090
|
+
* // encode boolean, number, or string to text before saving
|
|
7091
|
+
* column: t
|
|
7092
|
+
* .string()
|
|
7093
|
+
* // when having validation library, the first argument is a validation schema
|
|
7094
|
+
* .encode(
|
|
7095
|
+
* z.boolean().or(z.number()).or(z.string()),
|
|
7096
|
+
* (input: boolean | number | string) => String(input),
|
|
7097
|
+
* )
|
|
7098
|
+
* // no schema argument otherwise
|
|
7099
|
+
* .encode((input: boolean | number | string) => String(input)),
|
|
7100
|
+
* }));
|
|
7094
7101
|
*
|
|
7095
7102
|
* // numbers and booleans will be converted to a string:
|
|
7096
7103
|
* await db.table.create({ column: 123 });
|
|
@@ -7115,22 +7122,19 @@ declare abstract class Column {
|
|
|
7115
7122
|
* import { z } from 'zod';
|
|
7116
7123
|
* import { number, integer } from 'valibot';
|
|
7117
7124
|
*
|
|
7118
|
-
* export
|
|
7119
|
-
*
|
|
7120
|
-
*
|
|
7121
|
-
*
|
|
7122
|
-
*
|
|
7123
|
-
*
|
|
7124
|
-
*
|
|
7125
|
-
*
|
|
7126
|
-
*
|
|
7127
|
-
*
|
|
7128
|
-
*
|
|
7129
|
-
*
|
|
7130
|
-
*
|
|
7131
|
-
* .parse((input) => parseInt(input)),
|
|
7132
|
-
* }));
|
|
7133
|
-
* }
|
|
7125
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7126
|
+
* columnZod: t
|
|
7127
|
+
* .string()
|
|
7128
|
+
* // when having validation library, the first argument is a schema
|
|
7129
|
+
* .parse(z.number().int(), (input) => parseInt(input))
|
|
7130
|
+
* // no schema argument otherwise
|
|
7131
|
+
* .parse((input) => parseInt(input)),
|
|
7132
|
+
*
|
|
7133
|
+
* columnValibot: t
|
|
7134
|
+
* .string()
|
|
7135
|
+
* .parse(number([integer()]), (input) => parseInt(input))
|
|
7136
|
+
* .parse((input) => parseInt(input)),
|
|
7137
|
+
* }));
|
|
7134
7138
|
*
|
|
7135
7139
|
* // column will be parsed to a number
|
|
7136
7140
|
* const value: number = await db.table.get('column');
|
|
@@ -7145,16 +7149,13 @@ declare abstract class Column {
|
|
|
7145
7149
|
* The `parseNull` function is only triggered for `nullable` columns.
|
|
7146
7150
|
*
|
|
7147
7151
|
* ```ts
|
|
7148
|
-
* export
|
|
7149
|
-
*
|
|
7150
|
-
*
|
|
7151
|
-
*
|
|
7152
|
-
*
|
|
7153
|
-
*
|
|
7154
|
-
*
|
|
7155
|
-
* .nullable(),
|
|
7156
|
-
* }));
|
|
7157
|
-
* }
|
|
7152
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7153
|
+
* column: t
|
|
7154
|
+
* .integer()
|
|
7155
|
+
* .parse(String) // parse non-nulls to string
|
|
7156
|
+
* .parseNull(() => false), // replace nulls with false
|
|
7157
|
+
* .nullable(),
|
|
7158
|
+
* }));
|
|
7158
7159
|
*
|
|
7159
7160
|
* const record = await db.table.take()
|
|
7160
7161
|
* record.column // can be a string or boolean, not null
|
|
@@ -7164,23 +7165,20 @@ declare abstract class Column {
|
|
|
7164
7165
|
* first argument is a schema for validating the output.
|
|
7165
7166
|
*
|
|
7166
7167
|
* ```ts
|
|
7167
|
-
* export
|
|
7168
|
-
*
|
|
7169
|
-
*
|
|
7170
|
-
*
|
|
7171
|
-
*
|
|
7172
|
-
* .parse(z.string(), String) // parse non-nulls to string
|
|
7173
|
-
* .parseNull(z.literal(false), () => false), // replace nulls with false
|
|
7168
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7169
|
+
* column: t
|
|
7170
|
+
* .integer()
|
|
7171
|
+
* .parse(z.string(), String) // parse non-nulls to string
|
|
7172
|
+
* .parseNull(z.literal(false), () => false) // replace nulls with false
|
|
7174
7173
|
* .nullable(),
|
|
7175
|
-
*
|
|
7176
|
-
* }
|
|
7174
|
+
* }));
|
|
7177
7175
|
*
|
|
7178
|
-
* const record = await db.table.take()
|
|
7179
|
-
* record.column // can be a string or boolean, not null
|
|
7176
|
+
* const record = await db.table.take();
|
|
7177
|
+
* record.column; // can be a string or boolean, not null
|
|
7180
7178
|
*
|
|
7181
7179
|
* Table.outputSchema().parse({
|
|
7182
7180
|
* column: false, // the schema expects strings or `false` literals, not nulls
|
|
7183
|
-
* })
|
|
7181
|
+
* });
|
|
7184
7182
|
* ```
|
|
7185
7183
|
*/
|
|
7186
7184
|
parseNull: this['__schema']['parseNull'];
|
|
@@ -7222,12 +7220,9 @@ declare abstract class Column {
|
|
|
7222
7220
|
* When _not_ integrating with [validation libraries](/guide/columns-validation-methods), `narrowType` has the following syntax:
|
|
7223
7221
|
*
|
|
7224
7222
|
* ```ts
|
|
7225
|
-
* export
|
|
7226
|
-
*
|
|
7227
|
-
*
|
|
7228
|
-
* size: t.string().narrowType((t) => t<'small' | 'medium' | 'large'>()),
|
|
7229
|
-
* }));
|
|
7230
|
-
* }
|
|
7223
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7224
|
+
* size: t.string().narrowType((t) => t<'small' | 'medium' | 'large'>()),
|
|
7225
|
+
* }));
|
|
7231
7226
|
*
|
|
7232
7227
|
* // size will be typed as 'small' | 'medium' | 'large'
|
|
7233
7228
|
* const size = await db.table.get('size');
|
|
@@ -7246,12 +7241,9 @@ declare abstract class Column {
|
|
|
7246
7241
|
* z.literal('large'),
|
|
7247
7242
|
* ]);
|
|
7248
7243
|
*
|
|
7249
|
-
* export
|
|
7250
|
-
*
|
|
7251
|
-
*
|
|
7252
|
-
* size: t.text().narrowType(sizeSchema),
|
|
7253
|
-
* }));
|
|
7254
|
-
* }
|
|
7244
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7245
|
+
* size: t.text().narrowType(sizeSchema),
|
|
7246
|
+
* }));
|
|
7255
7247
|
*
|
|
7256
7248
|
* // size will be typed as 'small' | 'medium' | 'large'
|
|
7257
7249
|
* const size = await db.table.get('size');
|
|
@@ -7268,21 +7260,18 @@ declare abstract class Column {
|
|
|
7268
7260
|
* When _not_ integrating with [validation libraries](/guide/columns-validation-methods), `narrowAllTypes` has the following syntax:
|
|
7269
7261
|
*
|
|
7270
7262
|
* ```ts
|
|
7271
|
-
* export
|
|
7272
|
-
*
|
|
7273
|
-
*
|
|
7274
|
-
*
|
|
7275
|
-
*
|
|
7276
|
-
*
|
|
7277
|
-
*
|
|
7278
|
-
*
|
|
7279
|
-
*
|
|
7280
|
-
*
|
|
7281
|
-
*
|
|
7282
|
-
*
|
|
7283
|
-
* ),
|
|
7284
|
-
* }));
|
|
7285
|
-
* }
|
|
7263
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7264
|
+
* size: t.string().narrowAllTypes((t) =>
|
|
7265
|
+
* t<{
|
|
7266
|
+
* // what types are accepted when creating/updating
|
|
7267
|
+
* input: 'small' | 'medium' | 'large';
|
|
7268
|
+
* // how types are retured from a database
|
|
7269
|
+
* output: 'small' | 'medium' | 'large';
|
|
7270
|
+
* // what types the column accepts in `where` and similar
|
|
7271
|
+
* query: 'small' | 'medium' | 'large';
|
|
7272
|
+
* }>(),
|
|
7273
|
+
* ),
|
|
7274
|
+
* }));
|
|
7286
7275
|
*
|
|
7287
7276
|
* // size will be typed as 'small' | 'medium' | 'large'
|
|
7288
7277
|
* const size = await db.table.get('size');
|
|
@@ -7301,16 +7290,13 @@ declare abstract class Column {
|
|
|
7301
7290
|
* z.literal('large'),
|
|
7302
7291
|
* ]);
|
|
7303
7292
|
*
|
|
7304
|
-
* export
|
|
7305
|
-
*
|
|
7306
|
-
*
|
|
7307
|
-
*
|
|
7308
|
-
*
|
|
7309
|
-
*
|
|
7310
|
-
*
|
|
7311
|
-
* }),
|
|
7312
|
-
* }));
|
|
7313
|
-
* }
|
|
7293
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7294
|
+
* size: t.text().narrowAllTypes({
|
|
7295
|
+
* input: sizeSchema,
|
|
7296
|
+
* output: sizeSchema,
|
|
7297
|
+
* query: sizeSchema,
|
|
7298
|
+
* }),
|
|
7299
|
+
* }));
|
|
7314
7300
|
*
|
|
7315
7301
|
* // size will be typed as 'small' | 'medium' | 'large'
|
|
7316
7302
|
* const size = await db.table.get('size');
|
|
@@ -7339,14 +7325,11 @@ declare abstract class Column {
|
|
|
7339
7325
|
* It won't be selected with `selectAll` or `select('*')` as well.
|
|
7340
7326
|
*
|
|
7341
7327
|
* ```ts
|
|
7342
|
-
* export
|
|
7343
|
-
*
|
|
7344
|
-
*
|
|
7345
|
-
*
|
|
7346
|
-
*
|
|
7347
|
-
* password: t.string().select(false),
|
|
7348
|
-
* }));
|
|
7349
|
-
* }
|
|
7328
|
+
* export const UserTable = defineTable('user', (t) => ({
|
|
7329
|
+
* id: t.identity().primaryKey(),
|
|
7330
|
+
* name: t.string(),
|
|
7331
|
+
* password: t.string().select(false),
|
|
7332
|
+
* }));
|
|
7350
7333
|
*
|
|
7351
7334
|
* // only id and name are selected, without password
|
|
7352
7335
|
* const user = await db.user.find(123);
|
|
@@ -7369,7 +7352,7 @@ declare abstract class Column {
|
|
|
7369
7352
|
* const userWithPassword = await db.user.find(123).select('*', 'password');
|
|
7370
7353
|
* ```
|
|
7371
7354
|
*/
|
|
7372
|
-
select<T extends Column.Pick.Data, Value extends boolean>(this: T, value: Value): Column.
|
|
7355
|
+
select<T extends Column.Pick.Data, Value extends boolean>(this: T, value: Value): Column.DefaultSelect<T, Value>;
|
|
7373
7356
|
/**
|
|
7374
7357
|
* Set SQL to use when selecting this column.
|
|
7375
7358
|
*
|
|
@@ -7385,26 +7368,23 @@ declare abstract class Column {
|
|
|
7385
7368
|
* `readOnly` column can be used together with a `default`.
|
|
7386
7369
|
*
|
|
7387
7370
|
* ```ts
|
|
7388
|
-
* export
|
|
7389
|
-
*
|
|
7390
|
-
*
|
|
7391
|
-
*
|
|
7392
|
-
*
|
|
7393
|
-
*
|
|
7394
|
-
*
|
|
7395
|
-
*
|
|
7396
|
-
* init(orm: typeof db) {
|
|
7397
|
-
* this.beforeSave(({ set }) => {
|
|
7371
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7372
|
+
* id: t.identity().primaryKey(),
|
|
7373
|
+
* column: t.string().default(() => 'default value'),
|
|
7374
|
+
* another: t.string().nullable().readOnly(),
|
|
7375
|
+
* })).init((orm: typeof db, hooks) => {
|
|
7376
|
+
* hooks.beforeSave(({ columns, set }) => {
|
|
7377
|
+
* if (columns.include('column')) {
|
|
7398
7378
|
* set({ another: 'value' });
|
|
7399
|
-
* }
|
|
7400
|
-
* }
|
|
7401
|
-
* }
|
|
7379
|
+
* }
|
|
7380
|
+
* });
|
|
7381
|
+
* });
|
|
7402
7382
|
*
|
|
7403
7383
|
* // later in the code
|
|
7404
7384
|
* db.table.create({ column: 'value' }); // TS error, runtime error
|
|
7405
7385
|
* ```
|
|
7406
7386
|
*/
|
|
7407
|
-
readOnly<T>(this: T): T & Column.
|
|
7387
|
+
readOnly<T>(this: T): T & Column.IsAppReadOnly;
|
|
7408
7388
|
/**
|
|
7409
7389
|
* Set a column value when creating a record.
|
|
7410
7390
|
* This works for [readOnly](#readonly) columns as well.
|
|
@@ -7412,13 +7392,15 @@ declare abstract class Column {
|
|
|
7412
7392
|
* If no value or undefined is returned, the hook won't have any effect.
|
|
7413
7393
|
*
|
|
7414
7394
|
* ```ts
|
|
7415
|
-
* export
|
|
7416
|
-
*
|
|
7417
|
-
*
|
|
7418
|
-
*
|
|
7419
|
-
*
|
|
7420
|
-
*
|
|
7421
|
-
*
|
|
7395
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7396
|
+
* id: t.identity().primaryKey(),
|
|
7397
|
+
* some: t.number(),
|
|
7398
|
+
* column: t
|
|
7399
|
+
* .string()
|
|
7400
|
+
* .setOnCreate(({ columns }) =>
|
|
7401
|
+
* columns.include('some') ? 'value' : undefined,
|
|
7402
|
+
* ),
|
|
7403
|
+
* }));
|
|
7422
7404
|
* ```
|
|
7423
7405
|
*/
|
|
7424
7406
|
setOnCreate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
|
|
@@ -7429,13 +7411,15 @@ declare abstract class Column {
|
|
|
7429
7411
|
* If no value or undefined is returned, the hook won't have any effect.
|
|
7430
7412
|
*
|
|
7431
7413
|
* ```ts
|
|
7432
|
-
* export
|
|
7433
|
-
*
|
|
7434
|
-
*
|
|
7435
|
-
*
|
|
7436
|
-
*
|
|
7437
|
-
*
|
|
7438
|
-
*
|
|
7414
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7415
|
+
* id: t.identity().primaryKey(),
|
|
7416
|
+
* some: t.number(),
|
|
7417
|
+
* column: t
|
|
7418
|
+
* .string()
|
|
7419
|
+
* .setOnUpdate(({ columns }) =>
|
|
7420
|
+
* columns.include('some') ? 'value' : undefined,
|
|
7421
|
+
* ),
|
|
7422
|
+
* }));
|
|
7439
7423
|
* ```
|
|
7440
7424
|
*/
|
|
7441
7425
|
setOnUpdate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
|
|
@@ -7446,13 +7430,15 @@ declare abstract class Column {
|
|
|
7446
7430
|
* If no value or undefined is returned, the hook won't have any effect.
|
|
7447
7431
|
*
|
|
7448
7432
|
* ```ts
|
|
7449
|
-
* export
|
|
7450
|
-
*
|
|
7451
|
-
*
|
|
7452
|
-
*
|
|
7453
|
-
*
|
|
7454
|
-
*
|
|
7455
|
-
*
|
|
7433
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7434
|
+
* id: t.identity().primaryKey(),
|
|
7435
|
+
* some: t.number(),
|
|
7436
|
+
* column: t
|
|
7437
|
+
* .string()
|
|
7438
|
+
* .setOnSave(({ columns }) =>
|
|
7439
|
+
* columns.include('some') ? 'value' : undefined,
|
|
7440
|
+
* ),
|
|
7441
|
+
* }));
|
|
7456
7442
|
* ```
|
|
7457
7443
|
*/
|
|
7458
7444
|
setOnSave<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
|
|
@@ -7465,14 +7451,11 @@ declare abstract class Column {
|
|
|
7465
7451
|
* Using `primaryKey` on a `uuid` column will automatically add a [gen_random_uuid](https://www.postgresql.org/docs/current/functions-uuid.html) default.
|
|
7466
7452
|
*
|
|
7467
7453
|
* ```ts
|
|
7468
|
-
* export
|
|
7469
|
-
*
|
|
7470
|
-
*
|
|
7471
|
-
*
|
|
7472
|
-
*
|
|
7473
|
-
* id: t.uuid().primaryKey('primary_key_name'),
|
|
7474
|
-
* }));
|
|
7475
|
-
* }
|
|
7454
|
+
* export const Table = defineTable('table', (t) => ({
|
|
7455
|
+
* id: t.uuid().primaryKey(),
|
|
7456
|
+
* // optionally, specify a database-level constraint name:
|
|
7457
|
+
* id: t.uuid().primaryKey('primary_key_name'),
|
|
7458
|
+
* }));
|
|
7476
7459
|
*
|
|
7477
7460
|
* // primary key can be used by `find` later:
|
|
7478
7461
|
* db.table.find('97ba9e78-7510-415a-9c03-23d440aec443');
|
|
@@ -7480,7 +7463,7 @@ declare abstract class Column {
|
|
|
7480
7463
|
*
|
|
7481
7464
|
* @param name - to specify a constraint name
|
|
7482
7465
|
*/
|
|
7483
|
-
primaryKey<T extends Column.Pick.Data, Name extends string>(this: T, name?: Name): T & Column.
|
|
7466
|
+
primaryKey<T extends Column.Pick.Data, Name extends string>(this: T, name?: Name): T & Column.IsPrimaryKey<Name>;
|
|
7484
7467
|
/**
|
|
7485
7468
|
* Defines a reference between different tables to enforce data integrity.
|
|
7486
7469
|
*
|
|
@@ -7499,12 +7482,9 @@ declare abstract class Column {
|
|
|
7499
7482
|
* In the migration it's different from OrchidORM table code where a callback with a table is expected:
|
|
7500
7483
|
*
|
|
7501
7484
|
* ```ts
|
|
7502
|
-
* export
|
|
7503
|
-
*
|
|
7504
|
-
*
|
|
7505
|
-
* otherTableId: t.integer().foreignKey(() => OtherTable, 'id'),
|
|
7506
|
-
* }));
|
|
7507
|
-
* }
|
|
7485
|
+
* export const SomeTable = defineTable('someTable', (t) => ({
|
|
7486
|
+
* otherTableId: t.integer().foreignKey(() => OtherTable, 'id'),
|
|
7487
|
+
* }));
|
|
7508
7488
|
* ```
|
|
7509
7489
|
*
|
|
7510
7490
|
* Optionally you can pass the third argument to `foreignKey` with options:
|
|
@@ -7555,11 +7535,7 @@ declare abstract class Column {
|
|
|
7555
7535
|
* @param column - column in the foreign table to connect with
|
|
7556
7536
|
* @param options - {@link ForeignKeyOptions}
|
|
7557
7537
|
*/
|
|
7558
|
-
foreignKey<T,
|
|
7559
|
-
columns: {
|
|
7560
|
-
shape: Shape;
|
|
7561
|
-
};
|
|
7562
|
-
}, column: keyof Shape, options?: TableData.References.Options): T;
|
|
7538
|
+
foreignKey<T, Table extends Column.ForeignKey.TableParam>(this: T, fn: () => Table, column: Column.ForeignKey.ColumnNameOfTable<Table>, options?: TableData.References.Options): T;
|
|
7563
7539
|
foreignKey<T, Table extends string, Column extends string>(this: T, table: Table, column: Column, options?: TableData.References.Options): T;
|
|
7564
7540
|
toSQL(): string;
|
|
7565
7541
|
/**
|
|
@@ -7717,7 +7693,7 @@ declare abstract class Column {
|
|
|
7717
7693
|
data: Column['data'];
|
|
7718
7694
|
dataType: string;
|
|
7719
7695
|
}>(this: T, ...args: [options?: TableData.Index.TsVectorColumnArg]): T;
|
|
7720
|
-
unique<T extends Column.Pick.Data, const Options extends TableData.Index.UniqueColumnArg>(this: T, ...args: [options?: Options]): T & Column.
|
|
7696
|
+
unique<T extends Column.Pick.Data, const Options extends TableData.Index.UniqueColumnArg>(this: T, ...args: [options?: Options]): T & Column.IsUnique<Options['name'] & string>;
|
|
7721
7697
|
/**
|
|
7722
7698
|
* Add [EXCLUDE constraint](https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-EXCLUDE) to the column.
|
|
7723
7699
|
*
|
|
@@ -7783,7 +7759,7 @@ declare abstract class Column {
|
|
|
7783
7759
|
*
|
|
7784
7760
|
* @param args - raw SQL
|
|
7785
7761
|
*/
|
|
7786
|
-
generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs): Column.
|
|
7762
|
+
generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs): Column.Generated<T>;
|
|
7787
7763
|
}
|
|
7788
7764
|
interface ColumnFromDbParams {
|
|
7789
7765
|
isNullable?: boolean;
|
|
@@ -7873,14 +7849,14 @@ declare class QueryCreateFrom {
|
|
|
7873
7849
|
* @param query - query to create new records from
|
|
7874
7850
|
* @param data - additionally you can set some columns
|
|
7875
7851
|
*/
|
|
7876
|
-
createOneFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data?:
|
|
7852
|
+
createOneFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data?: CreateDataOmit<T, Q['result'] extends never ? never : keyof Q['result']>): CreateRawOrFromResult<T>;
|
|
7877
7853
|
/**
|
|
7878
7854
|
* Works exactly as {@link createOneFrom}, except that it returns inserted row count by default.
|
|
7879
7855
|
*
|
|
7880
7856
|
* @param query - query to create new records from
|
|
7881
7857
|
* @param data - additionally you can set some columns
|
|
7882
7858
|
*/
|
|
7883
|
-
insertOneFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data?:
|
|
7859
|
+
insertOneFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data?: CreateDataOmit<T, Q['result'] extends never ? never : keyof Q['result']>): InsertRawOrFromResult<T>;
|
|
7884
7860
|
/**
|
|
7885
7861
|
* Inserts multiple records based on a query that selects a single record.
|
|
7886
7862
|
*
|
|
@@ -7940,14 +7916,14 @@ declare class QueryCreateFrom {
|
|
|
7940
7916
|
* @param query - query to create new records from
|
|
7941
7917
|
* @param data - array of records to create
|
|
7942
7918
|
*/
|
|
7943
|
-
createManyFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data:
|
|
7919
|
+
createManyFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data: CreateDataOmit<T, Q['result'] extends never ? never : keyof Q['result']>[]): CreateManyFromResult<T>;
|
|
7944
7920
|
/**
|
|
7945
7921
|
* Works exactly as {@link createManyFrom}, except that it returns inserted row count by default.
|
|
7946
7922
|
*
|
|
7947
7923
|
* @param query - query to create new records from
|
|
7948
7924
|
* @param data - array of records to create
|
|
7949
7925
|
*/
|
|
7950
|
-
insertManyFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data:
|
|
7926
|
+
insertManyFrom<T extends CreateSelf, Q extends QueryReturningOne>(this: T, query: Q, data: CreateDataOmit<T, Q['result'] extends never ? never : keyof Q['result']>[]): InsertManyFromResult<T>;
|
|
7951
7927
|
/**
|
|
7952
7928
|
* Inserts a single record per every record found in a given query.
|
|
7953
7929
|
*
|
|
@@ -7975,10 +7951,17 @@ declare class QueryCreateFrom {
|
|
|
7975
7951
|
}
|
|
7976
7952
|
interface CreateSelf extends PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryRelationsDataForCreate, PickQueryRelationsDataForCreateOptional, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType, Query.Pick.IsNotReadOnly {}
|
|
7977
7953
|
type CreateData<T extends CreateSelf> = EmptyObject extends T['relations'] ? CreateDataWithDefaults<T, keyof T['__defaults']> : CreateRelationsData<T>;
|
|
7954
|
+
type CreateDataOmit<T extends CreateSelf, OmitKeys> = EmptyObject extends T['relations'] ? CreateDataWithDefaultsOmit<T, keyof T['__defaults'], OmitKeys> : CreateRelationsDataOmit<T, OmitKeys>;
|
|
7978
7955
|
type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = { [K in keyof T['__inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults]?: K extends keyof T['__inputType'] ? CreateColumn<T, K> : never };
|
|
7979
|
-
type
|
|
7956
|
+
type CreateDataWithDefaultsOmit<T extends CreateSelf, Defaults extends PropertyKey, OmitKeys> = { [K in keyof T['__inputType'] as K extends Defaults | OmitKeys ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults as K extends OmitKeys ? never : K]?: K extends keyof T['__inputType'] ? CreateColumn<T, K> : never };
|
|
7957
|
+
type WritableForeignKeys<T extends CreateSelf, AllFKeys extends PropertyKey> = AllFKeys extends infer K ? K extends keyof T['shape'] ? T['shape'][K] extends {
|
|
7958
|
+
data: {
|
|
7959
|
+
makeColumnWritable: true;
|
|
7960
|
+
};
|
|
7961
|
+
} ? K : never : never : never;
|
|
7980
7962
|
type CreateColumn<T extends CreateSelf, K extends keyof T['__inputType']> = T['__inputType'][K] | ((q: T) => QueryOrExpression<T['__inputType'][K]>);
|
|
7981
|
-
type CreateRelationsData<T extends CreateSelf> =
|
|
7963
|
+
type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsOmit<T, keyof T['__defaults'], Exclude<T['relations'][keyof T['relations']]['omitForeignKeyInCreate'], WritableForeignKeys<T, T['relations'][keyof T['relations']]['omitForeignKeyInCreate']>>> & CreateRelationsDataOmittingFKeys<T, T['relationsDataForCreate']> & T['relationsDataForCreateOptional'];
|
|
7964
|
+
type CreateRelationsDataOmit<T extends CreateSelf, OmitKeys> = CreateDataWithDefaultsOmit<T, keyof T['__defaults'], Exclude<T['relations'][keyof T['relations']]['omitForeignKeyInCreate'], WritableForeignKeys<T, T['relations'][keyof T['relations']]['omitForeignKeyInCreate']>> | OmitKeys> & CreateRelationsDataOmittingFKeys<T, T['relationsDataForCreate']> & T['relationsDataForCreateOptional'];
|
|
7982
7965
|
type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Data> = EmptyObject extends Data ? EmptyObject : { [K in keyof Data]: CreateRelationDataOmittingFKeys<T, Data[K]> }[keyof Data] extends ((u: infer Obj) => void) ? Obj : never;
|
|
7983
7966
|
type CreateRelationDataOmittingFKeys<T extends CreateSelf, Union> = (u: Union extends RelationConfigDataForCreate ? Union['columns'] extends keyof T['__defaults'] ? Pick<CreateDataWithDefaults<T, keyof T['__defaults']>, Union['columns']> & Partial<Union['nested']> : (Pick<{ [P in keyof T['__inputType']]: CreateColumn<T, P> }, Union['columns'] & keyof T['__inputType']> & { [K in keyof Union['nested']]?: never }) | Union['nested'] : Union) => void;
|
|
7984
7967
|
type CreateResult<T extends CreateSelf, Data> = T extends {
|
|
@@ -8196,31 +8179,26 @@ declare class QueryCreate {
|
|
|
8196
8179
|
* A primary key or a unique index for a **single** column can be fined on a column:
|
|
8197
8180
|
*
|
|
8198
8181
|
* ```ts
|
|
8199
|
-
* export
|
|
8200
|
-
*
|
|
8201
|
-
*
|
|
8202
|
-
*
|
|
8203
|
-
* }));
|
|
8204
|
-
* }
|
|
8182
|
+
* export const MyTable = defineTable('myTable', (t) => ({
|
|
8183
|
+
* pkey: t.uuid().primaryKey(),
|
|
8184
|
+
* unique: t.string().unique(),
|
|
8185
|
+
* }));
|
|
8205
8186
|
* ```
|
|
8206
8187
|
*
|
|
8207
8188
|
* But for composite primary keys or indexes (having multiple columns), define it in a separate function:
|
|
8208
8189
|
*
|
|
8209
8190
|
* ```ts
|
|
8210
|
-
* export
|
|
8211
|
-
*
|
|
8212
|
-
*
|
|
8213
|
-
*
|
|
8214
|
-
*
|
|
8215
|
-
*
|
|
8216
|
-
*
|
|
8217
|
-
* (t) => [t.primaryKey(['one', 'two']), t.unique(['two', 'three'])],
|
|
8218
|
-
* );
|
|
8219
|
-
* }
|
|
8191
|
+
* export const MyTable = defineTable('myTable', (t) => ({
|
|
8192
|
+
* one: t.integer(),
|
|
8193
|
+
* two: t.string(),
|
|
8194
|
+
* three: t.boolean(),
|
|
8195
|
+
* }))
|
|
8196
|
+
* .primaryKey(['one', 'two'])
|
|
8197
|
+
* .unique(['two', 'three']);
|
|
8220
8198
|
* ```
|
|
8221
8199
|
* :::
|
|
8222
8200
|
*
|
|
8223
|
-
* You can use the `sql` function exported from your
|
|
8201
|
+
* You can use the `sql` function exported from your table factory file in onConflict.
|
|
8224
8202
|
* It can be useful to specify a condition when you have a partial index:
|
|
8225
8203
|
*
|
|
8226
8204
|
* ```ts
|
|
@@ -8378,7 +8356,7 @@ interface UpdateManyBySelf extends UpdateSelf {
|
|
|
8378
8356
|
uniqueConstraints: unknown;
|
|
8379
8357
|
};
|
|
8380
8358
|
}
|
|
8381
|
-
type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends Column.
|
|
8359
|
+
type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends Column.IsPrimaryKey<string> ? K : never]: T['shape'][K]['__queryType'] | Expression } & { [P in keyof T['__inputType']]?: T['__inputType'][P] | Expression })[];
|
|
8382
8360
|
type UpdateManyByKeys<T extends UpdateManyBySelf> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'];
|
|
8383
8361
|
type UpdateManyByKeyColumns<K> = K extends string[] ? K[number] : K;
|
|
8384
8362
|
type UpdateManyByData<T extends UpdateSelf, K> = ({ [P in K & keyof T['__inputType']]: T['__inputType'][P] } & { [P in keyof T['__inputType']]?: P extends K ? T['__inputType'][P] : T['__inputType'][P] | Expression })[];
|
|
@@ -9135,6 +9113,8 @@ interface QueryData extends QueryDataAliases, PickQueryDataParsers, HasHookSelec
|
|
|
9135
9113
|
/** upsert **/
|
|
9136
9114
|
upsertUpdate?: boolean;
|
|
9137
9115
|
upsertSecond?: boolean;
|
|
9116
|
+
upsertUpdateAsFns?: AsFn[];
|
|
9117
|
+
upsertCreateWith?: WithItems;
|
|
9138
9118
|
upsertCreateAppendQueries?: SubQueryForSql[];
|
|
9139
9119
|
upsertCreateAsFns?: AsFn[];
|
|
9140
9120
|
upsertInsert?(): unknown;
|
|
@@ -9428,14 +9408,11 @@ declare class CteQuery {
|
|
|
9428
9408
|
* For the first example, consider the employee table, an employee may or may not have a manager.
|
|
9429
9409
|
*
|
|
9430
9410
|
* ```ts
|
|
9431
|
-
*
|
|
9432
|
-
*
|
|
9433
|
-
*
|
|
9434
|
-
*
|
|
9435
|
-
*
|
|
9436
|
-
* managerId: t.integer().nullable(),
|
|
9437
|
-
* }));
|
|
9438
|
-
* }
|
|
9411
|
+
* export const Employee = defineTable('employee', (t) => ({
|
|
9412
|
+
* id: t.identity().primaryKey(),
|
|
9413
|
+
* name: t.string(),
|
|
9414
|
+
* managerId: t.integer().nullable(),
|
|
9415
|
+
* }));
|
|
9439
9416
|
* ```
|
|
9440
9417
|
*
|
|
9441
9418
|
* The task is to load all subordinates of the manager with the id 1.
|
|
@@ -10223,7 +10200,7 @@ interface NarrowValueTypeResult<T extends PickQueryResultReturnType, Narrow> ext
|
|
|
10223
10200
|
interface NarrowPluckTypeResult<T extends PickQueryResultReturnType, Narrow> extends Column.QueryColumns {
|
|
10224
10201
|
pluck: { [K in keyof T['result']['pluck']]: K extends '__outputType' ? Narrow extends unknown[] ? Narrow[number] : Narrow : T['result']['pluck'][K] };
|
|
10225
10202
|
}
|
|
10226
|
-
type QueryIfResult<T extends PickQueryResultReturnType, R extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? { [K in keyof T['result'] | keyof R['result']]: K extends keyof T['result'] ? K extends keyof R['result'] ? R['result'][K] | T['result'][K] : T['result'][K] : Column.
|
|
10203
|
+
type QueryIfResult<T extends PickQueryResultReturnType, R extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? { [K in keyof T['result'] | keyof R['result']]: K extends keyof T['result'] ? K extends keyof R['result'] ? R['result'][K] | T['result'][K] : T['result'][K] : Column.QueryColumnToOptional<R['result'][K]> } : K extends 'then' ? QueryIfResultThen<T, R> : T[K] };
|
|
10227
10204
|
type QueryIfResultThen<T extends PickQueryResultReturnType, R extends PickQueryResult> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'value' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType']> : T['returnType'] extends 'rows' ? QueryThen<(T['result'][keyof T['result']]['__outputType'] | R['result'][keyof R['result']]['__outputType'])[][]> : T['returnType'] extends 'pluck' ? QueryThen<(T['result']['pluck']['__outputType'] | R['result']['pluck']['__outputType'])[]> : QueryThen<void>;
|
|
10228
10205
|
interface QueryMethods<ColumnTypes> extends QueryClone, QueryAsMethods, AggregateMethods, QueryDistinct, Select, FromMethods, QueryJoin, QueryLimitOffset, CteQuery, Union, QueryJsonMethods, QueryCreate, QueryCreateFrom, QueryUpdate, QueryDelete, QueryStorage, QueryTransaction, QueryTruncate, For, Where, SearchMethods, Clear, Having, QueryCatchers, QueryLog, QueryOrder, QueryWithSchema, QueryHooks, QueryUpsert, QueryOrCreate, QueryGet, QueryPluck, MergeQueryMethods, QuerySql<ColumnTypes>, QueryTransform, QueryMap, QueryScope, SoftDeleteMethods, QueryExpressions, QueryWrap, QueryWindow, QueryExistsMethods {}
|
|
10229
10206
|
declare class QueryMethods<ColumnTypes> {
|
|
@@ -10808,7 +10785,7 @@ type SetQueryReturnsPluckColumnResult<T extends PickQueryResult, Result extends
|
|
|
10808
10785
|
} : K extends 'returnType' ? 'pluck' : K extends 'result' ? Result : K extends 'then' ? QueryThen<T['result']['value']['__outputType'][]> : T[K] } & QueryHasSelect;
|
|
10809
10786
|
type SetQueryReturnsValueOrThrow<T extends PickQuerySelectable, Arg extends keyof T['__selectable']> = SetQueryReturnsColumnOrThrow<T, T['__selectable'][Arg]['column']> & T['__selectable'][Arg]['column']['operators'];
|
|
10810
10787
|
type SetValueQueryReturnsValueOrThrow<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<T['result']['value']['__outputType']> : T[K] };
|
|
10811
|
-
type SetQueryReturnsValueOptional<T extends PickQuerySelectable, Arg extends GetStringArg<T>> = SetQueryReturnsColumnOptional<T, { [K in keyof T['__selectable'][Arg]['column']]: K extends '__outputType' ? T['__selectable'][Arg]['column'][K] | undefined : T['__selectable'][Arg]['column'][K] }> & Omit<T['__selectable'][Arg]['column']['operators'], 'equals' | 'not'> & Column.
|
|
10788
|
+
type SetQueryReturnsValueOptional<T extends PickQuerySelectable, Arg extends GetStringArg<T>> = SetQueryReturnsColumnOptional<T, { [K in keyof T['__selectable'][Arg]['column']]: K extends '__outputType' ? T['__selectable'][Arg]['column'][K] | undefined : T['__selectable'][Arg]['column'][K] }> & Omit<T['__selectable'][Arg]['column']['operators'], 'equals' | 'not'> & Column.OperatorsNullable<T['__selectable'][Arg]['column']>;
|
|
10812
10789
|
type SetQueryReturnsColumnOrThrow<T, Column extends Column.Pick.OutputType> = { [K in keyof T]: K extends 'result' ? {
|
|
10813
10790
|
value: Column;
|
|
10814
10791
|
} : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Column['__outputType']> : T[K] } & QueryHasSelect;
|
|
@@ -11026,6 +11003,8 @@ declare abstract class QueryAsMethods {
|
|
|
11026
11003
|
}
|
|
11027
11004
|
declare const _appendQuery: (main: Query, append: Query, asFn: (as: string) => void) => Query;
|
|
11028
11005
|
declare const _appendQueryOnUpsertCreate: (main: Query, append: Query, asFn: (as: string) => void) => Query;
|
|
11006
|
+
declare const _onUpsertUpdate: (q: Query, asFn: (as: string) => void) => Query;
|
|
11007
|
+
declare const _prependWithOnUpsertCreate: (q: Query, name: string | ((as: string) => void), query: Query) => void;
|
|
11029
11008
|
interface RefreshMaterializedViewOptions {
|
|
11030
11009
|
/**
|
|
11031
11010
|
* Refresh the materialized view without blocking concurrent selects.
|
|
@@ -11195,4 +11174,4 @@ declare const testTransaction: {
|
|
|
11195
11174
|
*/
|
|
11196
11175
|
close(arg: Arg$1): Promise<void>;
|
|
11197
11176
|
};
|
|
11198
|
-
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, type OperatorsText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RefreshMaterializedViewOptions, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, refreshMaterializedView, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|
|
11177
|
+
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, type OperatorsText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RefreshMaterializedViewOptions, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _onUpsertUpdate, _orCreate, _prependWith, _prependWithOnUpsertCreate, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, constraintToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, indexToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, refreshMaterializedView, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|