orchid-orm 1.72.7 → 1.72.9
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/bun.d.ts +13 -6
- package/dist/bun.js +5 -2
- package/dist/bun.js.map +1 -1
- package/dist/bun.mjs +6 -3
- package/dist/bun.mjs.map +1 -1
- package/dist/index.d.ts +234 -165
- package/dist/index.js +97 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -17
- package/dist/index.mjs.map +1 -1
- package/dist/migrations/index.js +435 -41
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +436 -42
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/node-postgres.d.ts +14 -6
- package/dist/node-postgres.js +5 -2
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs +6 -3
- package/dist/node-postgres.mjs.map +1 -1
- package/dist/postgres-js.d.ts +13 -6
- package/dist/postgres-js.js +5 -2
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs +6 -3
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +5 -5
package/dist/bun.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import * as _$pqb_internal0 from "pqb/internal";
|
|
2
|
-
import { DbSharedOptions } from "pqb/internal";
|
|
2
|
+
import { DbSharedOptions, EmptyObject } from "pqb/internal";
|
|
3
3
|
import * as _$pqb_bun0 from "pqb/bun";
|
|
4
4
|
import { BunAdapterOptions, bunSchemaConfig } from "pqb/bun";
|
|
5
|
-
import { OrchidORM,
|
|
6
|
-
interface BunOrchidORMOptions extends BunAdapterOptions, DbSharedOptions {
|
|
5
|
+
import { OrchidORM, OrchidORMBundle, OrchidOrmParam, TableClasses } from "orchid-orm";
|
|
6
|
+
interface BunOrchidORMOptions extends BunAdapterOptions, DbSharedOptions {
|
|
7
|
+
views?: TableClasses;
|
|
8
|
+
}
|
|
7
9
|
declare const Adapter: _$pqb_internal0.DriverAdapter;
|
|
8
10
|
declare const createDb: <SchemaConfig extends _$pqb_internal0.ColumnSchemaConfig = _$pqb_internal0.DefaultSchemaConfig, ColumnTypes = _$pqb_internal0.DefaultColumnTypes<SchemaConfig>>({
|
|
9
11
|
log,
|
|
10
12
|
...options
|
|
11
13
|
}: _$pqb_bun0.CreateBunDbOptions<SchemaConfig, ColumnTypes>) => _$pqb_internal0.DbResult<ColumnTypes>;
|
|
12
|
-
declare const makeOrchidOrmDb: <T extends TableClasses>(orm:
|
|
14
|
+
declare const makeOrchidOrmDb: <T extends TableClasses, V extends TableClasses = EmptyObject>(orm: OrchidORMBundle<T, V>, {
|
|
13
15
|
log,
|
|
14
16
|
...options
|
|
15
|
-
}: OrchidOrmParam<BunOrchidORMOptions>) => OrchidORM<T>;
|
|
16
|
-
declare const orchidORM: <T extends TableClasses
|
|
17
|
+
}: OrchidOrmParam<BunOrchidORMOptions>) => OrchidORM<T, V>;
|
|
18
|
+
declare const orchidORM: <T extends TableClasses, V extends TableClasses = EmptyObject>({
|
|
19
|
+
views,
|
|
20
|
+
...options
|
|
21
|
+
}: OrchidOrmParam<BunOrchidORMOptions & {
|
|
22
|
+
views?: V;
|
|
23
|
+
}>, tables: T) => OrchidORM<T, V>;
|
|
17
24
|
export { Adapter, BunOrchidORMOptions, bunSchemaConfig, createDb, makeOrchidOrmDb, orchidORM };
|
package/dist/bun.js
CHANGED
|
@@ -14,8 +14,11 @@ const makeOrchidOrmDb = (orm, { log, ...options }) => {
|
|
|
14
14
|
})
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
const orchidORM = (options, tables) => {
|
|
18
|
-
return makeOrchidOrmDb((0, orchid_orm.
|
|
17
|
+
const orchidORM = ({ views, ...options }, tables) => {
|
|
18
|
+
return makeOrchidOrmDb((0, orchid_orm.bundleOrchidORM)({
|
|
19
|
+
tables,
|
|
20
|
+
views
|
|
21
|
+
}), options);
|
|
19
22
|
};
|
|
20
23
|
exports.Adapter = Adapter;
|
|
21
24
|
Object.defineProperty(exports, "bunSchemaConfig", {
|
package/dist/bun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.js","names":["BunAdapter","cdb","AdapterClass"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n
|
|
1
|
+
{"version":3,"file":"bun.js","names":["BunAdapter","cdb","AdapterClass"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n OrchidORMBundle,\n OrchidOrmParam,\n bundleOrchidORM,\n makeOrchidOrmDbWithAdapter,\n} from 'orchid-orm';\nimport { BunAdapter, BunAdapterOptions, createDb as cdb } from 'pqb/bun';\nimport { DbSharedOptions, AdapterClass, EmptyObject } from 'pqb/internal';\nexport { bunSchemaConfig } from 'pqb/bun';\n\nexport interface BunOrchidORMOptions\n extends BunAdapterOptions, DbSharedOptions {\n views?: TableClasses;\n}\n\nexport const Adapter = BunAdapter;\n\nexport const createDb = cdb;\n\nexport const makeOrchidOrmDb = <\n T extends TableClasses,\n V extends TableClasses = EmptyObject,\n>(\n orm: OrchidORMBundle<T, V>,\n { log, ...options }: OrchidOrmParam<BunOrchidORMOptions>,\n): OrchidORM<T, V> => {\n return makeOrchidOrmDbWithAdapter(orm, {\n ...options,\n log,\n adapter: new AdapterClass({\n driverAdapter: BunAdapter,\n config: options,\n }),\n });\n};\n\nexport const orchidORM = <\n T extends TableClasses,\n V extends TableClasses = EmptyObject,\n>(\n { views, ...options }: OrchidOrmParam<BunOrchidORMOptions & { views?: V }>,\n tables: T,\n): OrchidORM<T, V> => {\n const orm = bundleOrchidORM({ tables, views });\n return makeOrchidOrmDb(orm, options);\n};\n"],"mappings":";;;;AAiBA,MAAa,UAAUA,QAAAA;AAEvB,MAAa,WAAWC,QAAAA;AAExB,MAAa,mBAIX,KACA,EAAE,KAAK,GAAG,cACU;AACpB,SAAA,GAAA,WAAA,4BAAkC,KAAK;EACrC,GAAG;EACH;EACA,SAAS,IAAIC,aAAAA,aAAa;GACxB,eAAeF,QAAAA;GACf,QAAQ;GACT,CAAC;EACH,CAAC;;AAGJ,MAAa,aAIX,EAAE,OAAO,GAAG,WACZ,WACoB;AAEpB,QAAO,iBAAA,GAAA,WAAA,iBADqB;EAAE;EAAQ;EAAO,CAAC,EAClB,QAAQ"}
|
package/dist/bun.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bundleOrchidORM, makeOrchidOrmDbWithAdapter } from "orchid-orm";
|
|
2
2
|
import { BunAdapter, bunSchemaConfig, createDb as createDb$1 } from "pqb/bun";
|
|
3
3
|
import { AdapterClass } from "pqb/internal";
|
|
4
4
|
const Adapter = BunAdapter;
|
|
@@ -13,8 +13,11 @@ const makeOrchidOrmDb = (orm, { log, ...options }) => {
|
|
|
13
13
|
})
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
const orchidORM = (options, tables) => {
|
|
17
|
-
return makeOrchidOrmDb(
|
|
16
|
+
const orchidORM = ({ views, ...options }, tables) => {
|
|
17
|
+
return makeOrchidOrmDb(bundleOrchidORM({
|
|
18
|
+
tables,
|
|
19
|
+
views
|
|
20
|
+
}), options);
|
|
18
21
|
};
|
|
19
22
|
export { Adapter, bunSchemaConfig, createDb, makeOrchidOrmDb, orchidORM };
|
|
20
23
|
|
package/dist/bun.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.mjs","names":["cdb"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n
|
|
1
|
+
{"version":3,"file":"bun.mjs","names":["cdb"],"sources":["../src/adapters/bun.ts"],"sourcesContent":["import {\n TableClasses,\n OrchidORM,\n OrchidORMBundle,\n OrchidOrmParam,\n bundleOrchidORM,\n makeOrchidOrmDbWithAdapter,\n} from 'orchid-orm';\nimport { BunAdapter, BunAdapterOptions, createDb as cdb } from 'pqb/bun';\nimport { DbSharedOptions, AdapterClass, EmptyObject } from 'pqb/internal';\nexport { bunSchemaConfig } from 'pqb/bun';\n\nexport interface BunOrchidORMOptions\n extends BunAdapterOptions, DbSharedOptions {\n views?: TableClasses;\n}\n\nexport const Adapter = BunAdapter;\n\nexport const createDb = cdb;\n\nexport const makeOrchidOrmDb = <\n T extends TableClasses,\n V extends TableClasses = EmptyObject,\n>(\n orm: OrchidORMBundle<T, V>,\n { log, ...options }: OrchidOrmParam<BunOrchidORMOptions>,\n): OrchidORM<T, V> => {\n return makeOrchidOrmDbWithAdapter(orm, {\n ...options,\n log,\n adapter: new AdapterClass({\n driverAdapter: BunAdapter,\n config: options,\n }),\n });\n};\n\nexport const orchidORM = <\n T extends TableClasses,\n V extends TableClasses = EmptyObject,\n>(\n { views, ...options }: OrchidOrmParam<BunOrchidORMOptions & { views?: V }>,\n tables: T,\n): OrchidORM<T, V> => {\n const orm = bundleOrchidORM({ tables, views });\n return makeOrchidOrmDb(orm, options);\n};\n"],"mappings":";;;AAiBA,MAAa,UAAU;AAEvB,MAAa,WAAWA;AAExB,MAAa,mBAIX,KACA,EAAE,KAAK,GAAG,cACU;AACpB,QAAO,2BAA2B,KAAK;EACrC,GAAG;EACH;EACA,SAAS,IAAI,aAAa;GACxB,eAAe;GACf,QAAQ;GACT,CAAC;EACH,CAAC;;AAGJ,MAAa,aAIX,EAAE,OAAO,GAAG,WACZ,WACoB;AAEpB,QAAO,gBADK,gBAAgB;EAAE;EAAQ;EAAO,CAAC,EAClB,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter, AfterCommitStandaloneHook, AfterHook, Column, ColumnSchemaConfig, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateData, CreateManyMethodsNames, CreateMethodsNames, CreateSelf, DbSharedOptions, DbSqlMethod, DbTableOptionScopes, DefaultColumnTypes, DefaultSchemaConfig, DeleteMethodsNames, EmptyObject, FromArg, FromResult, Grant, IsQuery, IsolationLevel, JoinQueryMethod, MapTableScopesOption, MaybeArray, MergeQuery, PickQuerySelectableRelations, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere,
|
|
1
|
+
import { Adapter, AfterCommitStandaloneHook, AfterHook, Column, ColumnSchemaConfig, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateData, CreateManyMethodsNames, CreateMethodsNames, CreateSelf, DbSharedOptions, DbSqlMethod, DbTableOptionScopes, DefaultColumnTypes, DefaultSchemaConfig, DeleteMethodsNames, EmptyObject, FromArg, FromResult, Grant, IsQuery, IsolationLevel, JoinQueryMethod, MapTableScopesOption, MaybeArray, MergeQuery, PickQuerySelectableRelations, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryReturnType, QuerySchema, QueryScopes, RawSqlBase, RecordUnknown, RelationConfigBase, Rls, SelectableFromShape, ShallowSimplify, ShapeColumnPrimaryKeys, ShapeUniqueColumns, StorageOptions, TableData, TableDataFn, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TransactionOptions, UniqueConstraints, UpdateData, WhereArg } from "pqb/internal";
|
|
2
2
|
import { Db, Query } from "pqb";
|
|
3
3
|
export * from "pqb";
|
|
4
4
|
interface RelationRefsOptions<Column extends PropertyKey = string, Shape extends Column.Shape.QueryInit = Column.Shape.QueryInit> {
|
|
@@ -25,15 +25,14 @@ type HasOneQueryThrough<Name extends string, TableQuery extends Query> = { [K in
|
|
|
25
25
|
type HasOneQuery<T extends RelationConfigSelf, Name extends string, TableQuery extends Query> = T['relations'][Name]['options'] extends RelationRefsOptions ? { [K in keyof TableQuery]: K extends '__defaults' ? { [K in keyof TableQuery['__defaults'] | T['relations'][Name]['options']['references'][number]]: true } : K extends '__selectable' ? SelectableFromShape<TableQuery['shape'], Name> : K extends '__as' ? Name : K extends CreateManyMethodsNames ? never : TableQuery[K] } & QueryHasWhere & HasRelJoin : HasOneQueryThrough<Name, TableQuery>;
|
|
26
26
|
interface HasOneInfo<T extends RelationConfigSelf, Name extends string, Rel extends HasOne, Q extends Query> extends RelationConfigBase {
|
|
27
27
|
returnsOne: true;
|
|
28
|
+
required: T['relations'][Name]['options']['required'];
|
|
28
29
|
query: Q;
|
|
29
30
|
params: HasOneParams<T, Rel['options']>;
|
|
30
|
-
maybeSingle: T['relations'][Name]['options']['required'] extends true ? QueryManyTake<Q> : QueryManyTakeOptional<Q>;
|
|
31
31
|
omitForeignKeyInCreate: never;
|
|
32
|
-
|
|
32
|
+
dataForCreate: { [K in Name]?: Q extends Query.Pick.IsNotReadOnly ? T['relations'][Name]['options'] extends RelationThroughOptions ? EmptyObject : RelationToOneDataForCreate<{
|
|
33
33
|
nestedCreateQuery: CreateData<Q>;
|
|
34
34
|
table: Q;
|
|
35
|
-
}>
|
|
36
|
-
dataForCreate: undefined;
|
|
35
|
+
}> : never };
|
|
37
36
|
dataForUpdate: Q extends Query.Pick.IsNotReadOnly ? {
|
|
38
37
|
disconnect: boolean;
|
|
39
38
|
} | {
|
|
@@ -67,17 +66,15 @@ interface HasManyInfo<T extends RelationConfigSelf, Name extends string, Rel ext
|
|
|
67
66
|
returnsOne: false;
|
|
68
67
|
query: Q;
|
|
69
68
|
params: HasOneParams<T, Rel['options']>;
|
|
70
|
-
maybeSingle: Q;
|
|
71
69
|
omitForeignKeyInCreate: never;
|
|
72
|
-
|
|
70
|
+
dataForCreate: { [K in Name]?: Q extends Query.Pick.IsNotReadOnly ? T['relations'][Name]['options'] extends RelationThroughOptions ? never : {
|
|
73
71
|
create?: CreateData<Q>[];
|
|
74
72
|
connect?: WhereArg<Q>[];
|
|
75
73
|
connectOrCreate?: {
|
|
76
74
|
where: WhereArg<Q>;
|
|
77
75
|
create: CreateData<Q>;
|
|
78
76
|
}[];
|
|
79
|
-
}
|
|
80
|
-
dataForCreate: undefined;
|
|
77
|
+
} : never };
|
|
81
78
|
dataForUpdate: Q extends Query.Pick.IsNotReadOnly ? {
|
|
82
79
|
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
83
80
|
delete?: MaybeArray<WhereArg<Q>>;
|
|
@@ -124,15 +121,14 @@ type BelongsToParams<T extends RelationConfigSelf, FK extends string> = { [Name
|
|
|
124
121
|
type BelongsToQuery<T extends Query, Name extends string> = { [P in keyof T]: P extends '__selectable' ? SelectableFromShape<T['shape'], Name> : P extends '__as' ? Name : P extends CreateMethodsNames | DeleteMethodsNames ? never : T[P] } & QueryHasWhere & HasRelJoin;
|
|
125
122
|
interface BelongsToInfo<T extends RelationConfigSelf, Name extends string, FK extends string, Required, Q extends Query> extends RelationConfigBase {
|
|
126
123
|
returnsOne: true;
|
|
124
|
+
required: Required;
|
|
127
125
|
query: Q;
|
|
128
126
|
params: BelongsToParams<T, FK>;
|
|
129
|
-
maybeSingle: Required extends true ? QueryManyTake<Q> : QueryManyTakeOptional<Q>;
|
|
130
127
|
omitForeignKeyInCreate: FK;
|
|
131
128
|
dataForCreate: {
|
|
132
129
|
columns: FK;
|
|
133
|
-
nested: Q extends Query.Pick.IsNotReadOnly ? Required extends true ? { [Key in Name]: RelationToOneDataForCreateSameQuery<Q> } : { [Key in Name]?: RelationToOneDataForCreateSameQuery<Q> } : never;
|
|
130
|
+
nested: Q extends Query.Pick.IsNotReadOnly ? Required extends true ? { [Key in Name]: RelationToOneDataForCreateSameQuery<Q> } : { [Key in Name]?: RelationToOneDataForCreateSameQuery<Q> } : { [Key in Name]?: never };
|
|
134
131
|
};
|
|
135
|
-
optionalDataForCreate: EmptyObject;
|
|
136
132
|
dataForUpdate: {
|
|
137
133
|
disconnect: boolean;
|
|
138
134
|
} | {
|
|
@@ -161,6 +157,132 @@ interface BelongsToInfo<T extends RelationConfigSelf, Name extends string, FK ex
|
|
|
161
157
|
};
|
|
162
158
|
} : never);
|
|
163
159
|
}
|
|
160
|
+
interface HasAndBelongsToMany extends RelationThunkBase {
|
|
161
|
+
type: 'hasAndBelongsToMany';
|
|
162
|
+
options: HasAndBelongsToManyOptions;
|
|
163
|
+
}
|
|
164
|
+
interface HasAndBelongsToManyOptions<Columns extends Column.Shape.QueryInit = Column.Shape.QueryInit, Related extends ORMTableInput = ORMTableInput> {
|
|
165
|
+
required?: boolean;
|
|
166
|
+
columns: (keyof Columns)[];
|
|
167
|
+
references: string[];
|
|
168
|
+
foreignKey?: boolean | TableData.References.Options;
|
|
169
|
+
through: {
|
|
170
|
+
schema?: QuerySchema;
|
|
171
|
+
table: string;
|
|
172
|
+
columns: string[];
|
|
173
|
+
references: (keyof Related['columns']['shape'])[];
|
|
174
|
+
foreignKey?: boolean | TableData.References.Options;
|
|
175
|
+
};
|
|
176
|
+
on?: ColumnsShape.InputPartial<Related['columns']['shape']>;
|
|
177
|
+
}
|
|
178
|
+
type HasAndBelongsToManyParams<T extends RelationConfigSelf, FK extends string> = { [Name in FK]: T['columns']['shape'][Name]['type'] };
|
|
179
|
+
type HasAndBelongsToManyQuery<Name extends string, TableQuery extends Query> = { [K in keyof TableQuery]: K extends '__selectable' ? SelectableFromShape<TableQuery['shape'], Name> : K extends '__as' ? Name : TableQuery[K] } & QueryHasWhere & HasRelJoin;
|
|
180
|
+
interface HasAndBelongsToManyInfo<T extends RelationConfigSelf, Name extends string, FK extends string, Q extends Query> extends RelationConfigBase {
|
|
181
|
+
returnsOne: false;
|
|
182
|
+
query: Q;
|
|
183
|
+
params: HasAndBelongsToManyParams<T, FK>;
|
|
184
|
+
omitForeignKeyInCreate: never;
|
|
185
|
+
dataForCreate: { [K in Name]?: Q extends Query.Pick.IsNotReadOnly ? {
|
|
186
|
+
create?: CreateData<Q>[];
|
|
187
|
+
connect?: WhereArg<Q>[];
|
|
188
|
+
connectOrCreate?: {
|
|
189
|
+
where: WhereArg<Q>;
|
|
190
|
+
create: CreateData<Q>;
|
|
191
|
+
}[];
|
|
192
|
+
} : {
|
|
193
|
+
connect?: WhereArg<Q>[];
|
|
194
|
+
} };
|
|
195
|
+
dataForUpdate: Q extends Query.Pick.IsNotReadOnly ? {
|
|
196
|
+
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
197
|
+
set?: MaybeArray<WhereArg<Q>>;
|
|
198
|
+
add?: MaybeArray<WhereArg<Q>>;
|
|
199
|
+
delete?: MaybeArray<WhereArg<Q>>;
|
|
200
|
+
update?: {
|
|
201
|
+
where: MaybeArray<WhereArg<Q>>;
|
|
202
|
+
data: UpdateData<Q>;
|
|
203
|
+
};
|
|
204
|
+
create?: CreateData<Q>[];
|
|
205
|
+
} : {
|
|
206
|
+
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
207
|
+
set?: MaybeArray<WhereArg<Q>>;
|
|
208
|
+
add?: MaybeArray<WhereArg<Q>>;
|
|
209
|
+
};
|
|
210
|
+
dataForUpdateOne: Q extends Query.Pick.IsNotReadOnly ? {
|
|
211
|
+
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
212
|
+
set?: MaybeArray<WhereArg<Q>>;
|
|
213
|
+
add?: MaybeArray<WhereArg<Q>>;
|
|
214
|
+
delete?: MaybeArray<WhereArg<Q>>;
|
|
215
|
+
update?: {
|
|
216
|
+
where: MaybeArray<WhereArg<Q>>;
|
|
217
|
+
data: UpdateData<Q>;
|
|
218
|
+
};
|
|
219
|
+
create?: CreateData<Q>[];
|
|
220
|
+
upsert?: {
|
|
221
|
+
findBy: Q['internal']['uniqueColumns'];
|
|
222
|
+
update: UpdateData<Q>;
|
|
223
|
+
create?: CreateData<Q> | (() => CreateData<Q>);
|
|
224
|
+
};
|
|
225
|
+
} : {
|
|
226
|
+
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
227
|
+
set?: MaybeArray<WhereArg<Q>>;
|
|
228
|
+
add?: MaybeArray<WhereArg<Q>>;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
type RelationToOneDataForCreate<Rel extends {
|
|
232
|
+
nestedCreateQuery: unknown;
|
|
233
|
+
table: Query;
|
|
234
|
+
}> = {
|
|
235
|
+
create: Rel['nestedCreateQuery'];
|
|
236
|
+
connect?: never;
|
|
237
|
+
connectOrCreate?: never;
|
|
238
|
+
} | {
|
|
239
|
+
create?: never;
|
|
240
|
+
connect: WhereArg<Rel['table']>;
|
|
241
|
+
connectOrCreate?: never;
|
|
242
|
+
} | {
|
|
243
|
+
create?: never;
|
|
244
|
+
connect?: never;
|
|
245
|
+
connectOrCreate: {
|
|
246
|
+
where: WhereArg<Rel['table']>;
|
|
247
|
+
create: Rel['nestedCreateQuery'];
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
interface RelationToOneDataForCreateSameQuerySelf extends CreateSelf, PickQuerySelectableRelations {}
|
|
251
|
+
type RelationToOneDataForCreateSameQuery<Q extends RelationToOneDataForCreateSameQuerySelf> = {
|
|
252
|
+
create: CreateData<Q>;
|
|
253
|
+
connect?: never;
|
|
254
|
+
connectOrCreate?: never;
|
|
255
|
+
} | {
|
|
256
|
+
create?: never;
|
|
257
|
+
connect: WhereArg<Q>;
|
|
258
|
+
connectOrCreate?: never;
|
|
259
|
+
} | {
|
|
260
|
+
create?: never;
|
|
261
|
+
connect?: never;
|
|
262
|
+
connectOrCreate: {
|
|
263
|
+
where: WhereArg<Q>;
|
|
264
|
+
create: CreateData<Q>;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
interface RelationThunkBase {
|
|
268
|
+
type: string;
|
|
269
|
+
related: ORMTableInput;
|
|
270
|
+
options: unknown;
|
|
271
|
+
}
|
|
272
|
+
type RelationThunk = BelongsTo | HasOne | HasMany | HasAndBelongsToMany;
|
|
273
|
+
interface RelationThunks {
|
|
274
|
+
[K: string]: RelationThunk;
|
|
275
|
+
}
|
|
276
|
+
type RelationTableToQuery<Relation> = Relation extends {
|
|
277
|
+
related: infer R extends ORMTableInput;
|
|
278
|
+
} ? TableToDb<R, R['table'] extends string ? R['table'] : R['name'], R['table'] extends string ? R['readOnly'] extends true ? true : undefined : R['readOnly'] extends false ? undefined : true> : never;
|
|
279
|
+
interface RelationConfigSelf {
|
|
280
|
+
columns: {
|
|
281
|
+
shape: Column.Shape.QueryInit;
|
|
282
|
+
};
|
|
283
|
+
relations: RelationThunks;
|
|
284
|
+
}
|
|
285
|
+
type RelationConfigParams<T extends RelationConfigSelf, Relation extends RelationThunk> = Relation extends BelongsTo ? BelongsToParams<T, Relation['options']['columns'][number] & string> : Relation extends HasOne | HasMany ? HasOneParams<T, Relation['options']> : Relation extends HasAndBelongsToMany ? HasAndBelongsToManyParams<T, Relation['options']['columns'][number] & string> : never;
|
|
164
286
|
declare function transaction<Result>(this: {
|
|
165
287
|
$qb: Db;
|
|
166
288
|
}, fn: () => Promise<Result>): Promise<Result>;
|
|
@@ -200,11 +322,22 @@ interface OrchidORMTableHelper<T extends Query> {
|
|
|
200
322
|
}
|
|
201
323
|
type OrchidORMTables<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
202
324
|
new (): infer R extends ORMTableInput;
|
|
203
|
-
} ? OrchidORMTableHelper<TableToDb<R>> : never };
|
|
325
|
+
} ? OrchidORMTableHelper<TableToDb<R, R['table'], R['readOnly'] extends true ? true : undefined>> : never };
|
|
326
|
+
type OrchidORMViews<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
327
|
+
new (): infer R extends ORMTableInput;
|
|
328
|
+
} ? OrchidORMTableHelper<TableToDb<R, R['name'], R['readOnly'] extends false ? undefined : true, R['materialized'] extends true ? true : undefined>> : never };
|
|
329
|
+
type OrchidORMBundle<T extends TableClasses = TableClasses, V extends TableClasses = TableClasses> = OrchidORMTables<T> & {
|
|
330
|
+
$views: OrchidORMViews<V>;
|
|
331
|
+
};
|
|
204
332
|
type OrchidORMDbTables<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
205
333
|
new (): infer R extends ORMTableInput;
|
|
206
|
-
} ? TableToDb<R> : never };
|
|
207
|
-
type
|
|
334
|
+
} ? TableToDb<R, R['table'], R['readOnly'] extends true ? true : undefined> : never };
|
|
335
|
+
type OrchidORMDbViews<T extends TableClasses = TableClasses> = { [K in keyof T]: T[K] extends {
|
|
336
|
+
new (): infer R extends ORMTableInput;
|
|
337
|
+
} ? TableToDb<R, R['name'], R['readOnly'] extends false ? undefined : true, R['materialized'] extends true ? true : undefined> : never };
|
|
338
|
+
type OrchidORM<T extends TableClasses = TableClasses, V extends TableClasses = TableClasses> = OrchidORMDbTables<T> & {
|
|
339
|
+
$views: OrchidORMDbViews<V>;
|
|
340
|
+
} & OrchidORMMethods;
|
|
208
341
|
/**
|
|
209
342
|
* Identity helper for table row-level security configuration.
|
|
210
343
|
*/
|
|
@@ -360,145 +493,30 @@ interface OrchidORMMethods {
|
|
|
360
493
|
$close(): Promise<void>;
|
|
361
494
|
}
|
|
362
495
|
type OrchidOrmParam<Options> = true | null extends true ? 'Set strict: true to tsconfig' : Options;
|
|
363
|
-
|
|
364
|
-
|
|
496
|
+
interface OrchidORMSetupOptions<V extends TableClasses = TableClasses> extends DbSharedOptions {
|
|
497
|
+
/**
|
|
498
|
+
* First-class regular views exposed under db.$views.
|
|
499
|
+
*/
|
|
500
|
+
views?: V;
|
|
501
|
+
}
|
|
502
|
+
declare const bundleOrchidORM: <T extends TableClasses = EmptyObject, V extends TableClasses = EmptyObject>({
|
|
503
|
+
tables,
|
|
504
|
+
views
|
|
505
|
+
}: {
|
|
506
|
+
tables?: T;
|
|
507
|
+
views?: V;
|
|
508
|
+
}) => OrchidORMBundle<T, V>;
|
|
509
|
+
declare const bundleOrchidORMTables: <T extends TableClasses>(tables: T) => OrchidORMBundle<T, EmptyObject>;
|
|
510
|
+
declare const makeOrchidOrmDbWithAdapter: <T extends TableClasses, V extends TableClasses>(orm: OrchidORMBundle<T, V>, options: OrchidOrmParam<({
|
|
365
511
|
db: Query;
|
|
366
512
|
} | {
|
|
367
513
|
adapter: Adapter;
|
|
368
|
-
}) & DbSharedOptions>) => OrchidORM<T>;
|
|
369
|
-
declare const orchidORMWithAdapter: <T extends TableClasses>(options: OrchidOrmParam<({
|
|
514
|
+
}) & DbSharedOptions>) => OrchidORM<T, V>;
|
|
515
|
+
declare const orchidORMWithAdapter: <T extends TableClasses, V extends TableClasses = EmptyObject>(options: OrchidOrmParam<({
|
|
370
516
|
db: Query;
|
|
371
517
|
} | {
|
|
372
518
|
adapter: Adapter;
|
|
373
|
-
}) &
|
|
374
|
-
interface HasAndBelongsToMany extends RelationThunkBase {
|
|
375
|
-
type: 'hasAndBelongsToMany';
|
|
376
|
-
options: HasAndBelongsToManyOptions;
|
|
377
|
-
}
|
|
378
|
-
interface HasAndBelongsToManyOptions<Columns extends Column.Shape.QueryInit = Column.Shape.QueryInit, Related extends ORMTableInput = ORMTableInput> {
|
|
379
|
-
required?: boolean;
|
|
380
|
-
columns: (keyof Columns)[];
|
|
381
|
-
references: string[];
|
|
382
|
-
foreignKey?: boolean | TableData.References.Options;
|
|
383
|
-
through: {
|
|
384
|
-
schema?: QuerySchema;
|
|
385
|
-
table: string;
|
|
386
|
-
columns: string[];
|
|
387
|
-
references: (keyof Related['columns']['shape'])[];
|
|
388
|
-
foreignKey?: boolean | TableData.References.Options;
|
|
389
|
-
};
|
|
390
|
-
on?: ColumnsShape.InputPartial<Related['columns']['shape']>;
|
|
391
|
-
}
|
|
392
|
-
type HasAndBelongsToManyParams<T extends RelationConfigSelf, FK extends string> = { [Name in FK]: T['columns']['shape'][Name]['type'] };
|
|
393
|
-
type HasAndBelongsToManyQuery<Name extends string, TableQuery extends Query> = { [K in keyof TableQuery]: K extends '__selectable' ? SelectableFromShape<TableQuery['shape'], Name> : K extends '__as' ? Name : TableQuery[K] } & QueryHasWhere & HasRelJoin;
|
|
394
|
-
interface HasAndBelongsToManyInfo<T extends RelationConfigSelf, Name extends string, FK extends string, Q extends Query> extends RelationConfigBase {
|
|
395
|
-
returnsOne: false;
|
|
396
|
-
query: Q;
|
|
397
|
-
params: HasAndBelongsToManyParams<T, FK>;
|
|
398
|
-
maybeSingle: Q;
|
|
399
|
-
omitForeignKeyInCreate: never;
|
|
400
|
-
optionalDataForCreate: { [P in Name]?: Q extends Query.Pick.IsNotReadOnly ? {
|
|
401
|
-
create?: CreateData<Q>[];
|
|
402
|
-
connect?: WhereArg<Q>[];
|
|
403
|
-
connectOrCreate?: {
|
|
404
|
-
where: WhereArg<Q>;
|
|
405
|
-
create: CreateData<Q>;
|
|
406
|
-
}[];
|
|
407
|
-
} : {
|
|
408
|
-
connect?: WhereArg<Q>[];
|
|
409
|
-
} };
|
|
410
|
-
dataForCreate: undefined;
|
|
411
|
-
dataForUpdate: Q extends Query.Pick.IsNotReadOnly ? {
|
|
412
|
-
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
413
|
-
set?: MaybeArray<WhereArg<Q>>;
|
|
414
|
-
add?: MaybeArray<WhereArg<Q>>;
|
|
415
|
-
delete?: MaybeArray<WhereArg<Q>>;
|
|
416
|
-
update?: {
|
|
417
|
-
where: MaybeArray<WhereArg<Q>>;
|
|
418
|
-
data: UpdateData<Q>;
|
|
419
|
-
};
|
|
420
|
-
create?: CreateData<Q>[];
|
|
421
|
-
} : {
|
|
422
|
-
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
423
|
-
set?: MaybeArray<WhereArg<Q>>;
|
|
424
|
-
add?: MaybeArray<WhereArg<Q>>;
|
|
425
|
-
};
|
|
426
|
-
dataForUpdateOne: Q extends Query.Pick.IsNotReadOnly ? {
|
|
427
|
-
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
428
|
-
set?: MaybeArray<WhereArg<Q>>;
|
|
429
|
-
add?: MaybeArray<WhereArg<Q>>;
|
|
430
|
-
delete?: MaybeArray<WhereArg<Q>>;
|
|
431
|
-
update?: {
|
|
432
|
-
where: MaybeArray<WhereArg<Q>>;
|
|
433
|
-
data: UpdateData<Q>;
|
|
434
|
-
};
|
|
435
|
-
create?: CreateData<Q>[];
|
|
436
|
-
upsert?: {
|
|
437
|
-
findBy: Q['internal']['uniqueColumns'];
|
|
438
|
-
update: UpdateData<Q>;
|
|
439
|
-
create?: CreateData<Q> | (() => CreateData<Q>);
|
|
440
|
-
};
|
|
441
|
-
} : {
|
|
442
|
-
disconnect?: MaybeArray<WhereArg<Q>>;
|
|
443
|
-
set?: MaybeArray<WhereArg<Q>>;
|
|
444
|
-
add?: MaybeArray<WhereArg<Q>>;
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
type RelationToOneDataForCreate<Rel extends {
|
|
448
|
-
nestedCreateQuery: unknown;
|
|
449
|
-
table: Query;
|
|
450
|
-
}> = {
|
|
451
|
-
create: Rel['nestedCreateQuery'];
|
|
452
|
-
connect?: never;
|
|
453
|
-
connectOrCreate?: never;
|
|
454
|
-
} | {
|
|
455
|
-
create?: never;
|
|
456
|
-
connect: WhereArg<Rel['table']>;
|
|
457
|
-
connectOrCreate?: never;
|
|
458
|
-
} | {
|
|
459
|
-
create?: never;
|
|
460
|
-
connect?: never;
|
|
461
|
-
connectOrCreate: {
|
|
462
|
-
where: WhereArg<Rel['table']>;
|
|
463
|
-
create: Rel['nestedCreateQuery'];
|
|
464
|
-
};
|
|
465
|
-
};
|
|
466
|
-
interface RelationToOneDataForCreateSameQuerySelf extends CreateSelf, PickQuerySelectableRelations {}
|
|
467
|
-
type RelationToOneDataForCreateSameQuery<Q extends RelationToOneDataForCreateSameQuerySelf> = {
|
|
468
|
-
create: CreateData<Q>;
|
|
469
|
-
connect?: never;
|
|
470
|
-
connectOrCreate?: never;
|
|
471
|
-
} | {
|
|
472
|
-
create?: never;
|
|
473
|
-
connect: WhereArg<Q>;
|
|
474
|
-
connectOrCreate?: never;
|
|
475
|
-
} | {
|
|
476
|
-
create?: never;
|
|
477
|
-
connect?: never;
|
|
478
|
-
connectOrCreate: {
|
|
479
|
-
where: WhereArg<Q>;
|
|
480
|
-
create: CreateData<Q>;
|
|
481
|
-
};
|
|
482
|
-
};
|
|
483
|
-
interface RelationThunkBase {
|
|
484
|
-
type: string;
|
|
485
|
-
related: ORMTableInput;
|
|
486
|
-
options: unknown;
|
|
487
|
-
}
|
|
488
|
-
type RelationThunk = BelongsTo | HasOne | HasMany | HasAndBelongsToMany;
|
|
489
|
-
interface RelationThunks {
|
|
490
|
-
[K: string]: RelationThunk;
|
|
491
|
-
}
|
|
492
|
-
type RelationTableToQuery<Relation> = Relation extends {
|
|
493
|
-
related: infer R extends ORMTableInput;
|
|
494
|
-
} ? TableToDb<R> : never;
|
|
495
|
-
interface RelationConfigSelf {
|
|
496
|
-
columns: {
|
|
497
|
-
shape: Column.Shape.QueryInit;
|
|
498
|
-
};
|
|
499
|
-
relations: RelationThunks;
|
|
500
|
-
}
|
|
501
|
-
type RelationConfigParams<T extends RelationConfigSelf, Relation extends RelationThunk> = Relation extends BelongsTo ? BelongsToParams<T, Relation['options']['columns'][number] & string> : Relation extends HasOne | HasMany ? HasOneParams<T, Relation['options']> : Relation extends HasAndBelongsToMany ? HasAndBelongsToManyParams<T, Relation['options']['columns'][number] & string> : never;
|
|
519
|
+
}) & OrchidORMSetupOptions<V>>, tables: T) => OrchidORM<T, V>;
|
|
502
520
|
interface TableClass<T extends ORMTableInput = ORMTableInput> {
|
|
503
521
|
new (): T;
|
|
504
522
|
}
|
|
@@ -512,24 +530,28 @@ interface TableInfo {
|
|
|
512
530
|
name: string;
|
|
513
531
|
}
|
|
514
532
|
interface Table extends Query, TableInfo {}
|
|
515
|
-
interface TableToDb<T extends ORMTableInput> extends TableInfo, Db<
|
|
533
|
+
interface TableToDb<T extends ORMTableInput, Name extends string | undefined, ReadOnly extends true | undefined, Materialized extends true | undefined = undefined> extends TableInfo, Db<Name, T['columns']['shape'], keyof ShapeColumnPrimaryKeys<T['columns']['shape']> extends never ? never : ShapeColumnPrimaryKeys<T['columns']['shape']>, ShapeUniqueColumns<T['columns']['shape']> | TableDataItemsUniqueColumns<T['columns']['shape'], T['columns']['data']>, TableDataItemsUniqueColumnTuples<T['columns']['shape'], T['columns']['data']>, UniqueConstraints<T['columns']['shape']> | TableDataItemsUniqueConstraints<T['columns']['data']>, T['types'], T['columns']['shape'] & ComputedColumnsFromOptions<T['computed']>, MapTableScopesOption<T>, ColumnsShape.DefaultSelectKeys<T['columns']['shape']>, ReadOnly, Materialized> {
|
|
516
534
|
relations: T extends RelationConfigSelf ? { [K in keyof T['relations'] & string]: T['relations'][K] extends BelongsTo ? BelongsToInfo<T, K, T['relations'][K]['options']['columns'][number] & string, T['relations'][K]['options']['required'], BelongsToQuery<RelationTableToQuery<T['relations'][K]>, K>> : T['relations'][K] extends HasOne ? HasOneInfo<T, K, T['relations'][K], HasOneQuery<T, K, RelationTableToQuery<T['relations'][K]>>> : T['relations'][K] extends HasMany ? HasManyInfo<T, K, T['relations'][K], HasManyQuery<T, K, RelationTableToQuery<T['relations'][K]>>> : T['relations'][K] extends HasAndBelongsToMany ? HasAndBelongsToManyInfo<T, K, T['relations'][K]['options']['columns'][number] & string, HasAndBelongsToManyQuery<K, RelationTableToQuery<T['relations'][K]>>> : never } : EmptyObject;
|
|
517
535
|
}
|
|
518
|
-
interface
|
|
519
|
-
table: string;
|
|
536
|
+
interface PickORMTableInputColumns {
|
|
520
537
|
columns: {
|
|
521
538
|
shape: Column.Shape.QueryInit;
|
|
522
539
|
data: MaybeArray<TableDataItem>;
|
|
523
540
|
};
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
noPrimaryKey?: boolean;
|
|
527
|
-
filePath: string;
|
|
528
|
-
language?: string;
|
|
541
|
+
}
|
|
542
|
+
interface PickORMTableComputed {
|
|
529
543
|
/**
|
|
530
544
|
* collect computed columns returned by {@link BaseTable.setColumns}
|
|
531
545
|
*/
|
|
532
546
|
computed?: ComputedOptionsFactory<never, never>;
|
|
547
|
+
}
|
|
548
|
+
interface PickORMTableInputColumnsAndComputed extends PickORMTableInputColumns, PickORMTableComputed {}
|
|
549
|
+
interface ORMTableInput extends PickORMTableInputColumnsAndComputed {
|
|
550
|
+
autoForeignKeys?: TableData.References.BaseOptions | boolean;
|
|
551
|
+
schema?: QuerySchema;
|
|
552
|
+
types: unknown;
|
|
553
|
+
filePath: string;
|
|
554
|
+
language?: string;
|
|
533
555
|
scopes?: RecordUnknown;
|
|
534
556
|
readonly softDelete?: true | string;
|
|
535
557
|
comment?: string;
|
|
@@ -539,17 +561,36 @@ interface ORMTableInput {
|
|
|
539
561
|
*/
|
|
540
562
|
grants?: readonly Grant.TableClassGrant[];
|
|
541
563
|
readonly readOnly?: boolean;
|
|
542
|
-
|
|
564
|
+
readonly materialized?: true;
|
|
565
|
+
/**
|
|
566
|
+
* Keep this table-like definition available at runtime, but exclude it from
|
|
567
|
+
* generated migration DDL reconciliation.
|
|
568
|
+
*/
|
|
569
|
+
generatorIgnore?: true;
|
|
570
|
+
table?: string;
|
|
571
|
+
noPrimaryKey?: boolean;
|
|
572
|
+
name?: string;
|
|
573
|
+
query?: Query;
|
|
574
|
+
sql?: string | RawSqlBase;
|
|
575
|
+
recursive?: boolean;
|
|
576
|
+
checkOption?: 'LOCAL' | 'CASCADED';
|
|
577
|
+
securityBarrier?: boolean;
|
|
578
|
+
securityInvoker?: boolean;
|
|
579
|
+
withData?: boolean;
|
|
543
580
|
}
|
|
544
|
-
type Queryable<T extends
|
|
545
|
-
type DefaultSelect<T extends
|
|
546
|
-
type Selectable<T extends
|
|
581
|
+
type Queryable<T extends PickORMTableInputColumns> = ShallowSimplify<{ [K in keyof T['columns']['shape']]?: T['columns']['shape'][K]['queryType'] }>;
|
|
582
|
+
type DefaultSelect<T extends PickORMTableInputColumns> = ShallowSimplify<ColumnsShape.DefaultOutput<T['columns']['shape']>>;
|
|
583
|
+
type Selectable<T extends PickORMTableInputColumnsAndComputed> = T['computed'] extends ((t: never) => infer R extends ComputedOptionsConfig) ? ShallowSimplify<ColumnsShape.Output<T['columns']['shape']> & { [K in keyof R]: R[K] extends {
|
|
584
|
+
result: {
|
|
585
|
+
value: infer Value extends Column.Pick.QueryColumn;
|
|
586
|
+
};
|
|
587
|
+
} ? Value['outputType'] : R[K] extends (() => {
|
|
547
588
|
result: {
|
|
548
589
|
value: infer Value extends Column.Pick.QueryColumn;
|
|
549
590
|
};
|
|
550
591
|
}) ? Value['outputType'] : never }> : ShallowSimplify<ColumnsShape.Output<T['columns']['shape']>>;
|
|
551
|
-
type Insertable<T extends
|
|
552
|
-
type Updatable<T extends
|
|
592
|
+
type Insertable<T extends PickORMTableInputColumns> = ShallowSimplify<ColumnsShape.Input<T['columns']['shape']>>;
|
|
593
|
+
type Updatable<T extends PickORMTableInputColumns> = ShallowSimplify<ColumnsShape.InputPartial<T['columns']['shape']>>;
|
|
553
594
|
type BeforeHookMethod = (cb: QueryBeforeHook) => void;
|
|
554
595
|
type BeforeActionHookMethod = (cb: QueryBeforeActionHook) => void;
|
|
555
596
|
type AfterHookMethod = (cb: QueryAfterHook) => void;
|
|
@@ -563,7 +604,7 @@ interface SetColumnsResult<Shape extends Column.Shape.QueryInit, Data extends Ma
|
|
|
563
604
|
data: Data extends unknown[] ? Data : [Data];
|
|
564
605
|
}
|
|
565
606
|
interface BaseTableInstance<ColumnTypes> {
|
|
566
|
-
table
|
|
607
|
+
table?: string;
|
|
567
608
|
columns: {
|
|
568
609
|
shape: Column.Shape.QueryInit;
|
|
569
610
|
data: MaybeArray<TableDataItem>;
|
|
@@ -575,6 +616,11 @@ interface BaseTableInstance<ColumnTypes> {
|
|
|
575
616
|
q: QueryData;
|
|
576
617
|
language?: string;
|
|
577
618
|
filePath: string;
|
|
619
|
+
/**
|
|
620
|
+
* Keep this table-like definition available at runtime, but exclude it from
|
|
621
|
+
* generated migration DDL reconciliation.
|
|
622
|
+
*/
|
|
623
|
+
generatorIgnore?: true;
|
|
578
624
|
result: Column.Shape.QueryInit;
|
|
579
625
|
clone<T extends IsQuery>(this: T): T;
|
|
580
626
|
getFilePath(): string;
|
|
@@ -677,8 +723,11 @@ interface BaseTableInstance<ColumnTypes> {
|
|
|
677
723
|
/**
|
|
678
724
|
* See {@link ScopeMethods}
|
|
679
725
|
*/
|
|
680
|
-
setScopes<Table extends string, Shape extends Column.Shape.QueryInit, Keys extends string>(this: {
|
|
726
|
+
setScopes<Table extends string, Shape extends Column.Shape.QueryInit, Keys extends string>(this: ({
|
|
681
727
|
table: Table;
|
|
728
|
+
} | {
|
|
729
|
+
name: Table;
|
|
730
|
+
}) & {
|
|
682
731
|
columns: {
|
|
683
732
|
shape: Shape;
|
|
684
733
|
};
|
|
@@ -748,6 +797,8 @@ interface BaseTableClass<SchemaConfig extends ColumnSchemaConfig, ColumnTypes> {
|
|
|
748
797
|
columnTypes: ColumnTypes;
|
|
749
798
|
getFilePath(): string;
|
|
750
799
|
sql: DbSqlMethod<ColumnTypes>;
|
|
800
|
+
View: TableClass<BaseViewInstance<ColumnTypes>>;
|
|
801
|
+
MaterializedView: TableClass<BaseMaterializedViewInstance<ColumnTypes>>;
|
|
751
802
|
new (): BaseTableInstance<ColumnTypes>;
|
|
752
803
|
instance(): BaseTableInstance<ColumnTypes>;
|
|
753
804
|
/**
|
|
@@ -777,6 +828,24 @@ interface BaseTableClass<SchemaConfig extends ColumnSchemaConfig, ColumnTypes> {
|
|
|
777
828
|
*/
|
|
778
829
|
updateSchema: SchemaConfig['updateSchema'];
|
|
779
830
|
}
|
|
831
|
+
interface BaseViewInstance<ColumnTypes> extends BaseTableInstance<ColumnTypes> {
|
|
832
|
+
name: string;
|
|
833
|
+
query?: Query;
|
|
834
|
+
sql: string | RawSqlBase;
|
|
835
|
+
readonly readOnly?: boolean;
|
|
836
|
+
recursive?: boolean;
|
|
837
|
+
checkOption?: 'LOCAL' | 'CASCADED';
|
|
838
|
+
securityBarrier?: boolean;
|
|
839
|
+
securityInvoker?: boolean;
|
|
840
|
+
}
|
|
841
|
+
interface BaseMaterializedViewInstance<ColumnTypes> extends BaseTableInstance<ColumnTypes> {
|
|
842
|
+
name: string;
|
|
843
|
+
query?: Query;
|
|
844
|
+
sql: string | RawSqlBase;
|
|
845
|
+
readonly readOnly?: true;
|
|
846
|
+
readonly materialized: true;
|
|
847
|
+
withData?: boolean;
|
|
848
|
+
}
|
|
780
849
|
declare function createBaseTable<SchemaConfig extends ColumnSchemaConfig = DefaultSchemaConfig, ColumnTypes = DefaultColumnTypes<SchemaConfig>>({
|
|
781
850
|
schemaConfig,
|
|
782
851
|
columnTypes: columnTypesArg,
|
|
@@ -812,4 +881,4 @@ declare const createRepo: <T extends Query, Methods extends MethodsBase<T>>(tabl
|
|
|
812
881
|
table: T["table"];
|
|
813
882
|
shape: T["shape"];
|
|
814
883
|
}>(q: Q) => Query & Q & MapMethods<T, Methods>) & T, Methods>;
|
|
815
|
-
export { BaseTableClass, BaseTableInstance, DefaultSelect, FromQuery, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, OrchidORM, OrchidORMDbTables, OrchidORMTableHelper, OrchidORMTables, OrchidOrmParam, Queryable, Repo, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable, bundleOrchidORMTables, createBaseTable, createRepo, defineRls, makeOrchidOrmDbWithAdapter, orchidORMWithAdapter, setGrants };
|
|
884
|
+
export { BaseMaterializedViewInstance, BaseTableClass, BaseTableInstance, BaseViewInstance, DefaultSelect, FromQuery, Insertable, MapMethods, MapQueryMethods, MethodsBase, ORMTableInput, OrchidORM, OrchidORMBundle, OrchidORMDbTables, OrchidORMDbViews, OrchidORMTableHelper, OrchidORMTables, OrchidORMViews, OrchidOrmParam, PickORMTableComputed, PickORMTableInputColumns, PickORMTableInputColumnsAndComputed, Queryable, Repo, Selectable, SetColumnsResult, Table, TableClass, TableClasses, TableInfo, TableToDb, Updatable, bundleOrchidORM, bundleOrchidORMTables, createBaseTable, createRepo, defineRls, makeOrchidOrmDbWithAdapter, orchidORMWithAdapter, setGrants };
|