@holo-js/media 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +44 -2796
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _holo_js_db from '@holo-js/db';
|
|
2
|
-
import { Entity
|
|
2
|
+
import { Entity, TableDefinition, ModelRecord, RelationMap, DynamicRelationResolver, ModelQueryBuilder, ModelRelationPath, RelationConstraintDefinition, RelatedColumnNameForRelationPath, ModelCollection, EntityWithLoaded, PaginatedResult, SimplePaginatedResult, CursorPaginatedResult, ResolveEagerLoads } from '@holo-js/db';
|
|
3
3
|
import { StorageContent } from '@holo-js/storage/runtime';
|
|
4
4
|
import { QueueJobDefinition, QueueJsonValue } from '@holo-js/queue';
|
|
5
5
|
|
|
@@ -96,2765 +96,6 @@ declare function normalizeMediaDefinition<TCollectionName extends string = strin
|
|
|
96
96
|
|
|
97
97
|
type BinaryContent = Exclude<StorageContent, string>;
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* Capability flags exposed by a driver+dialect pair.
|
|
101
|
-
*
|
|
102
|
-
* The new architecture uses explicit capabilities instead of branching on
|
|
103
|
-
* driver names throughout the ORM.
|
|
104
|
-
*/
|
|
105
|
-
interface DatabaseCapabilities {
|
|
106
|
-
returning: boolean;
|
|
107
|
-
savepoints: boolean;
|
|
108
|
-
concurrentQueries: boolean;
|
|
109
|
-
workerThreadExecution: boolean;
|
|
110
|
-
lockForUpdate: boolean;
|
|
111
|
-
sharedLock: boolean;
|
|
112
|
-
jsonValueQuery: boolean;
|
|
113
|
-
jsonContains: boolean;
|
|
114
|
-
jsonLength: boolean;
|
|
115
|
-
schemaQualifiedIdentifiers: boolean;
|
|
116
|
-
nativeUpsert: boolean;
|
|
117
|
-
ddlAlterSupport: boolean;
|
|
118
|
-
introspection: boolean;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
type LogicalColumnKind = 'id' | 'integer' | 'bigInteger' | 'string' | 'text' | 'boolean' | 'real' | 'decimal' | 'date' | 'datetime' | 'timestamp' | 'json' | 'blob' | 'uuid' | 'ulid' | 'snowflake' | 'vector' | 'enum';
|
|
122
|
-
type ColumnDefaultKind = 'value' | 'now';
|
|
123
|
-
type IdGenerationStrategy = 'autoIncrement' | 'uuid' | 'ulid' | 'snowflake';
|
|
124
|
-
type VectorValue = readonly number[];
|
|
125
|
-
interface ForeignKeyReference {
|
|
126
|
-
table: string;
|
|
127
|
-
column: string;
|
|
128
|
-
constraintName?: string;
|
|
129
|
-
onDelete?: string;
|
|
130
|
-
onUpdate?: string;
|
|
131
|
-
}
|
|
132
|
-
interface ColumnDefinition<_TType = unknown, TNullable extends boolean = false, THasDefault extends boolean = false, TGenerated extends boolean = false, TPrimaryKey extends boolean = false> {
|
|
133
|
-
readonly kind: LogicalColumnKind;
|
|
134
|
-
readonly name: string;
|
|
135
|
-
readonly nullable: TNullable;
|
|
136
|
-
readonly hasDefault: THasDefault;
|
|
137
|
-
readonly generated: TGenerated;
|
|
138
|
-
readonly primaryKey: TPrimaryKey;
|
|
139
|
-
readonly unique: boolean;
|
|
140
|
-
readonly defaultKind?: ColumnDefaultKind;
|
|
141
|
-
readonly defaultValue?: unknown;
|
|
142
|
-
readonly references?: ForeignKeyReference;
|
|
143
|
-
readonly idStrategy?: IdGenerationStrategy;
|
|
144
|
-
readonly enumValues?: readonly string[];
|
|
145
|
-
readonly vectorDimensions?: number;
|
|
146
|
-
}
|
|
147
|
-
type AnyColumnDefinition = ColumnDefinition<unknown, boolean, boolean, boolean, boolean>;
|
|
148
|
-
type TableColumnsShape = Record<string, AnyColumnDefinition>;
|
|
149
|
-
interface TableDefinition<TName extends string = string, TColumns extends TableColumnsShape = TableColumnsShape> {
|
|
150
|
-
readonly kind: 'table';
|
|
151
|
-
readonly tableName: TName;
|
|
152
|
-
readonly columns: TColumns;
|
|
153
|
-
readonly indexes: readonly TableIndexDefinition[];
|
|
154
|
-
}
|
|
155
|
-
interface TableIndexDefinition {
|
|
156
|
-
readonly name?: string;
|
|
157
|
-
readonly columns: readonly string[];
|
|
158
|
-
readonly unique: boolean;
|
|
159
|
-
}
|
|
160
|
-
type ColumnSelectType<TColumn extends AnyColumnDefinition> = TColumn extends ColumnDefinition<infer TValue, infer TNullable, boolean, boolean, boolean> ? TNullable extends true ? TValue | null : TValue : never;
|
|
161
|
-
type ColumnInsertType<TColumn extends AnyColumnDefinition> = TColumn extends ColumnDefinition<infer TValue, infer TNullable, boolean, boolean, boolean> ? TNullable extends true ? TValue | null : TValue : never;
|
|
162
|
-
type OptionalInsertKeys<TColumns extends TableColumnsShape> = {
|
|
163
|
-
[K in keyof TColumns]: TColumns[K] extends ColumnDefinition<unknown, boolean, infer THasDefault, infer TGenerated, boolean> ? THasDefault extends true ? K : TGenerated extends true ? K : never : never;
|
|
164
|
-
}[keyof TColumns];
|
|
165
|
-
type RequiredInsertKeys<TColumns extends TableColumnsShape> = Exclude<keyof TColumns, OptionalInsertKeys<TColumns>>;
|
|
166
|
-
type InferSelect<TTable extends TableDefinition> = {
|
|
167
|
-
[K in keyof TTable['columns']]: ColumnSelectType<TTable['columns'][K]>;
|
|
168
|
-
};
|
|
169
|
-
type InferInsert<TTable extends TableDefinition> = {
|
|
170
|
-
[K in RequiredInsertKeys<TTable['columns']>]: ColumnInsertType<TTable['columns'][K]>;
|
|
171
|
-
} & {
|
|
172
|
-
[K in OptionalInsertKeys<TTable['columns']>]?: ColumnInsertType<TTable['columns'][K]>;
|
|
173
|
-
};
|
|
174
|
-
type InferUpdate<TTable extends TableDefinition> = Partial<{
|
|
175
|
-
[K in keyof TTable['columns']]: ColumnInsertType<TTable['columns'][K]>;
|
|
176
|
-
}>;
|
|
177
|
-
|
|
178
|
-
type EntityConstructor = {
|
|
179
|
-
new <TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap>(repository: unknown, attributes: Partial<ModelRecord<TTable>>, exists?: boolean): Entity<TTable, TRelations>;
|
|
180
|
-
prototype: Entity<TableDefinition, RelationMap>;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
declare class EntityBase<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap> {
|
|
184
|
-
private readonly repository;
|
|
185
|
-
private attributes;
|
|
186
|
-
private original;
|
|
187
|
-
private changes;
|
|
188
|
-
private persisted;
|
|
189
|
-
private relations;
|
|
190
|
-
private relationLoads;
|
|
191
|
-
private peerCollection?;
|
|
192
|
-
private hiddenOverrides;
|
|
193
|
-
private visibleOverrides;
|
|
194
|
-
private visibleOnly;
|
|
195
|
-
private appendedOverrides;
|
|
196
|
-
constructor(repository: ModelRepositoryLike<TTable, EmptyScopeMap, TRelations>, attributes: Partial<ModelRecord<TTable>>, exists?: boolean);
|
|
197
|
-
getRepository(): ModelRepositoryLike<TTable>;
|
|
198
|
-
private getRepositoryRuntime;
|
|
199
|
-
is(other: unknown): boolean;
|
|
200
|
-
isNot(other: unknown): boolean;
|
|
201
|
-
exists(): boolean;
|
|
202
|
-
trashed(): boolean;
|
|
203
|
-
get<TKey extends Extract<keyof ModelRecord<TTable>, string>>(key: TKey): ModelRecord<TTable>[TKey];
|
|
204
|
-
set<TKey extends Extract<keyof ModelRecord<TTable>, string>>(key: TKey, value: ModelRecord<TTable>[TKey]): this;
|
|
205
|
-
fill(values: Partial<ModelRecord<TTable>>): this;
|
|
206
|
-
update(values: ModelUpdatePayload<TTable>): Promise<this>;
|
|
207
|
-
forceFill(values: Partial<ModelRecord<TTable>>): this;
|
|
208
|
-
isDirty(key?: Extract<keyof ModelRecord<TTable>, string>): boolean;
|
|
209
|
-
isClean(): boolean;
|
|
210
|
-
getDirty(): Partial<ModelUpdatePayload<TTable>>;
|
|
211
|
-
getChanges(): Partial<ModelUpdatePayload<TTable>>;
|
|
212
|
-
wasChanged(key?: Extract<keyof ModelRecord<TTable>, string>): boolean;
|
|
213
|
-
syncOriginal(): this;
|
|
214
|
-
syncChanges(): this;
|
|
215
|
-
syncPersisted(entity: EntityBase<TTable>, changes?: Record<string, unknown>): this;
|
|
216
|
-
bindPeerCollection(peers: readonly EntityBase<TTable, TRelations>[]): this;
|
|
217
|
-
getPeerCollection(): readonly EntityBase<TTable, TRelations>[] | undefined;
|
|
218
|
-
getPendingRelationLoad(name: string): Promise<unknown> | undefined;
|
|
219
|
-
setPendingRelationLoad(name: string, load: Promise<unknown>): this;
|
|
220
|
-
clearPendingRelationLoad(name: string): this;
|
|
221
|
-
toAttributes(): ModelRecord<TTable>;
|
|
222
|
-
setRelation(name: string, value: unknown): this;
|
|
223
|
-
setComputed(name: string, value: unknown): this;
|
|
224
|
-
makeHidden(...keys: readonly string[]): this;
|
|
225
|
-
makeVisible(...keys: readonly string[]): this;
|
|
226
|
-
setHidden(keys: readonly string[]): this;
|
|
227
|
-
setVisible(keys: readonly string[]): this;
|
|
228
|
-
append(...keys: readonly string[]): this;
|
|
229
|
-
setAppends(keys: readonly string[]): this;
|
|
230
|
-
withoutAppends(): this;
|
|
231
|
-
getRelation<TRelation = unknown>(name: string): TRelation;
|
|
232
|
-
hasRelation(name: string): boolean;
|
|
233
|
-
getLoadedRelations(): Readonly<Record<string, unknown>>;
|
|
234
|
-
getSerializationConfig(): {
|
|
235
|
-
readonly hidden: ReadonlySet<string>;
|
|
236
|
-
readonly visible: ReadonlySet<string>;
|
|
237
|
-
readonly visibleOnly: readonly string[] | null;
|
|
238
|
-
readonly appended: readonly string[] | null;
|
|
239
|
-
};
|
|
240
|
-
forgetRelation(name: string): this;
|
|
241
|
-
relation<K extends ModelRelationName<TRelations>>(name: K): RelationMethodsOf<TRelations[K]>;
|
|
242
|
-
toJSON(): ModelRecord<TTable>;
|
|
243
|
-
private applyPersistedEntity;
|
|
244
|
-
private persistEntity;
|
|
245
|
-
private deletePersistedEntity;
|
|
246
|
-
private restoreEntity;
|
|
247
|
-
private forceDeletePersistedEntity;
|
|
248
|
-
private loadAggregateDefinitions;
|
|
249
|
-
save(): Promise<this>;
|
|
250
|
-
push(): Promise<this>;
|
|
251
|
-
saveQuietly(): Promise<this>;
|
|
252
|
-
delete(): Promise<void>;
|
|
253
|
-
deleteQuietly(): Promise<void>;
|
|
254
|
-
restore(): Promise<this>;
|
|
255
|
-
restoreQuietly(): Promise<this>;
|
|
256
|
-
forceDelete(): Promise<void>;
|
|
257
|
-
forceDeleteQuietly(): Promise<void>;
|
|
258
|
-
fresh(): Promise<Entity<TTable, TRelations> | undefined>;
|
|
259
|
-
refresh(): Promise<this>;
|
|
260
|
-
replicate(except?: readonly string[]): Entity<TTable, TRelations>;
|
|
261
|
-
load<TPaths extends readonly ModelRelationPath<TRelations>[]>(...relations: TPaths): Promise<Omit<this, keyof ResolveEagerLoads<TRelations, TPaths>> & ResolveEagerLoads<TRelations, TPaths> & (this extends {
|
|
262
|
-
toJSON(): infer R;
|
|
263
|
-
} ? {
|
|
264
|
-
toJSON(): R & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
265
|
-
} : {
|
|
266
|
-
toJSON(): ModelRecord<TTable> & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
267
|
-
})>;
|
|
268
|
-
loadMissing<TPaths extends readonly ModelRelationPath<TRelations>[]>(...relations: TPaths): Promise<Omit<this, keyof ResolveEagerLoads<TRelations, TPaths>> & ResolveEagerLoads<TRelations, TPaths> & (this extends {
|
|
269
|
-
toJSON(): infer R;
|
|
270
|
-
} ? {
|
|
271
|
-
toJSON(): R & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
272
|
-
} : {
|
|
273
|
-
toJSON(): ModelRecord<TTable> & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
274
|
-
})>;
|
|
275
|
-
loadMorph(relation: ModelRelationName<TRelations>, mapping: ModelMorphLoadMap): Promise<this>;
|
|
276
|
-
loadCount(...relations: readonly ModelRelationName<TRelations>[]): Promise<this>;
|
|
277
|
-
loadExists(...relations: readonly ModelRelationName<TRelations>[]): Promise<this>;
|
|
278
|
-
loadSum<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<this>;
|
|
279
|
-
loadAvg<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<this>;
|
|
280
|
-
loadMin<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<this>;
|
|
281
|
-
loadMax<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<this>;
|
|
282
|
-
associate<TRelated extends TableDefinition>(relation: string, related: Entity<TRelated> | null): this;
|
|
283
|
-
dissociate(relation: string): this;
|
|
284
|
-
saveRelated<TRelated extends TableDefinition>(relation: string, related: Entity<TRelated>): Promise<Entity<TRelated>>;
|
|
285
|
-
saveManyRelated<TRelated extends TableDefinition>(relation: string, related: readonly Entity<TRelated>[]): Promise<Entity<TRelated>[]>;
|
|
286
|
-
saveRelatedQuietly<TRelated extends TableDefinition>(relation: string, related: Entity<TRelated>): Promise<Entity<TRelated>>;
|
|
287
|
-
saveManyRelatedQuietly<TRelated extends TableDefinition>(relation: string, related: readonly Entity<TRelated>[]): Promise<Entity<TRelated>[]>;
|
|
288
|
-
createRelated(relation: string, values: Record<string, unknown>): Promise<Entity<TableDefinition>>;
|
|
289
|
-
createManyRelated(relation: string, values: readonly Record<string, unknown>[]): Promise<Entity<TableDefinition>[]>;
|
|
290
|
-
createRelatedQuietly(relation: string, values: Record<string, unknown>): Promise<Entity<TableDefinition>>;
|
|
291
|
-
createManyRelatedQuietly(relation: string, values: readonly Record<string, unknown>[]): Promise<Entity<TableDefinition>[]>;
|
|
292
|
-
attach(relation: string, ids: unknown, attributes?: Record<string, unknown>): Promise<void>;
|
|
293
|
-
detach(relation: string, ids?: unknown): Promise<number>;
|
|
294
|
-
sync(relation: string, ids: unknown): Promise<{
|
|
295
|
-
attached: unknown[];
|
|
296
|
-
detached: unknown[];
|
|
297
|
-
updated: unknown[];
|
|
298
|
-
}>;
|
|
299
|
-
syncWithoutDetaching(relation: string, ids: unknown): Promise<{
|
|
300
|
-
attached: unknown[];
|
|
301
|
-
detached: unknown[];
|
|
302
|
-
updated: unknown[];
|
|
303
|
-
}>;
|
|
304
|
-
updateExistingPivot(relation: string, id: unknown, attributes: Record<string, unknown>): Promise<number>;
|
|
305
|
-
toggle(relation: string, ids: unknown): Promise<{
|
|
306
|
-
attached: unknown[];
|
|
307
|
-
detached: unknown[];
|
|
308
|
-
}>;
|
|
309
|
-
}
|
|
310
|
-
type ModelRelationMethods<TRelations extends RelationMap> = string extends ModelRelationName<TRelations> ? Record<never, never> : {
|
|
311
|
-
[K in ModelRelationName<TRelations>]: () => RelationMethodsOf<TRelations[K]>;
|
|
312
|
-
};
|
|
313
|
-
type ModelBase<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap> = EntityBase<TTable, TRelations> & ModelRecord<TTable> & {
|
|
314
|
-
relation<K extends ModelRelationName<TRelations>>(name: K): RelationMethodsOf<TRelations[K]>;
|
|
315
|
-
};
|
|
316
|
-
type Entity<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap> = ModelBase<TTable, TRelations> & ModelRelationMethods<TRelations>;
|
|
317
|
-
declare const Entity: EntityConstructor;
|
|
318
|
-
|
|
319
|
-
interface FactoryEntityReference<TTable extends TableDefinition = TableDefinition> {
|
|
320
|
-
attach(relation: string, ids: unknown, attributes?: Record<string, unknown>): Promise<void>;
|
|
321
|
-
exists(): boolean;
|
|
322
|
-
get(key: Extract<keyof ModelRecord<TTable>, string>): ModelRecord<TTable>[Extract<keyof ModelRecord<TTable>, string>];
|
|
323
|
-
set(key: Extract<keyof ModelRecord<TTable>, string>, value: ModelRecord<TTable>[Extract<keyof ModelRecord<TTable>, string>]): FactoryEntityReference<TTable>;
|
|
324
|
-
getRelation(name: string): unknown;
|
|
325
|
-
hasRelation(name: string): boolean;
|
|
326
|
-
setRelation(name: string, value: unknown): FactoryEntityReference<TTable>;
|
|
327
|
-
toAttributes(): Record<string, unknown>;
|
|
328
|
-
getRepository(): unknown;
|
|
329
|
-
}
|
|
330
|
-
interface FactoryModelReference<TTable extends TableDefinition = TableDefinition> {
|
|
331
|
-
readonly definition: {
|
|
332
|
-
table: TTable;
|
|
333
|
-
morphClass?: string;
|
|
334
|
-
};
|
|
335
|
-
getRepository(): unknown;
|
|
336
|
-
make(values?: Partial<ModelRecord<TTable>>): FactoryEntityReference<TTable>;
|
|
337
|
-
create(values?: Partial<ModelRecord<TTable>>): Promise<FactoryEntityReference<TTable>>;
|
|
338
|
-
getConnectionName?(): string | undefined;
|
|
339
|
-
}
|
|
340
|
-
interface FactoryContext<TModel extends FactoryModelReference = FactoryModelReference> {
|
|
341
|
-
readonly sequence: number;
|
|
342
|
-
readonly model: TModel;
|
|
343
|
-
}
|
|
344
|
-
type FactoryAttributes<TModel extends FactoryModelReference> = Partial<ModelRecord<TModel['definition']['table']>>;
|
|
345
|
-
type FactoryDefinition<TModel extends FactoryModelReference> = (context: FactoryContext<TModel>) => FactoryAttributes<TModel> | Promise<FactoryAttributes<TModel>>;
|
|
346
|
-
type FactoryStateDefinition<TModel extends FactoryModelReference> = FactoryAttributes<TModel> | ((attributes: FactoryAttributes<TModel>, context: FactoryContext<TModel>) => FactoryAttributes<TModel> | Promise<FactoryAttributes<TModel>>);
|
|
347
|
-
type FactoryHook<TModel extends FactoryModelReference> = (entity: FactoryEntityReference<TModel['definition']['table']>, context: FactoryContext<TModel>) => void | Promise<void>;
|
|
348
|
-
|
|
349
|
-
type RelatedEntity = FactoryEntityReference<TableDefinition>;
|
|
350
|
-
type FactorySource = {
|
|
351
|
-
readonly model: Pick<FactoryModelReference, 'definition' | 'getConnectionName' | 'getRepository'>;
|
|
352
|
-
getAmount(): number;
|
|
353
|
-
createOne(sequence?: number, overrides?: Record<string, unknown>): Promise<RelatedEntity>;
|
|
354
|
-
makeOne(sequence?: number, overrides?: Record<string, unknown>): Promise<RelatedEntity>;
|
|
355
|
-
createMany(amount?: number, overrides?: Record<string, unknown>): Promise<RelatedEntity[]>;
|
|
356
|
-
makeMany(amount?: number, overrides?: Record<string, unknown>): Promise<RelatedEntity[]>;
|
|
357
|
-
};
|
|
358
|
-
type ParentRelationSource = FactorySource | RelatedEntity;
|
|
359
|
-
type AttachedRelationSource = FactorySource | RelatedEntity | readonly RelatedEntity[];
|
|
360
|
-
declare class Factory<TModel extends FactoryModelReference = FactoryModelReference> {
|
|
361
|
-
readonly model: TModel;
|
|
362
|
-
private readonly definition;
|
|
363
|
-
private readonly states;
|
|
364
|
-
private readonly afterMakingHooks;
|
|
365
|
-
private readonly afterCreatingHooks;
|
|
366
|
-
private readonly recycledEntities;
|
|
367
|
-
private readonly parentRelations;
|
|
368
|
-
private readonly childRelations;
|
|
369
|
-
private readonly attachedRelations;
|
|
370
|
-
private readonly amount;
|
|
371
|
-
constructor(model: TModel, definition: FactoryDefinition<TModel>, options?: {
|
|
372
|
-
states?: readonly FactoryStateDefinition<TModel>[];
|
|
373
|
-
afterMakingHooks?: readonly FactoryHook<TModel>[];
|
|
374
|
-
afterCreatingHooks?: readonly FactoryHook<TModel>[];
|
|
375
|
-
recycledEntities?: readonly RelatedEntity[];
|
|
376
|
-
parentRelations?: ReadonlyArray<{
|
|
377
|
-
relation: string;
|
|
378
|
-
source: ParentRelationSource;
|
|
379
|
-
}>;
|
|
380
|
-
childRelations?: ReadonlyArray<{
|
|
381
|
-
relation: string;
|
|
382
|
-
factory: FactorySource;
|
|
383
|
-
}>;
|
|
384
|
-
attachedRelations?: ReadonlyArray<{
|
|
385
|
-
relation: string;
|
|
386
|
-
source: AttachedRelationSource;
|
|
387
|
-
pivotAttributes: Record<string, unknown>;
|
|
388
|
-
}>;
|
|
389
|
-
amount?: number;
|
|
390
|
-
});
|
|
391
|
-
count(amount: number): Factory<TModel>;
|
|
392
|
-
getAmount(): number;
|
|
393
|
-
state(definition: FactoryStateDefinition<TModel>): Factory<TModel>;
|
|
394
|
-
sequence(...definitions: readonly FactoryStateDefinition<TModel>[]): Factory<TModel>;
|
|
395
|
-
afterMaking(hook: FactoryHook<TModel>): Factory<TModel>;
|
|
396
|
-
afterCreating(hook: FactoryHook<TModel>): Factory<TModel>;
|
|
397
|
-
recycle(source: RelatedEntity | readonly RelatedEntity[]): Factory<TModel>;
|
|
398
|
-
for(source: ParentRelationSource, relation: string): Factory<TModel>;
|
|
399
|
-
has(factory: FactorySource, relation: string): Factory<TModel>;
|
|
400
|
-
hasAttached(source: AttachedRelationSource, relation: string, pivotAttributes?: Record<string, unknown>): Factory<TModel>;
|
|
401
|
-
raw(overrides?: FactoryAttributes<TModel>): Promise<FactoryAttributes<TModel> | FactoryAttributes<TModel>[]>;
|
|
402
|
-
make(overrides?: FactoryAttributes<TModel>): Promise<Entity<TModel['definition']['table']> | Array<Entity<TModel['definition']['table']>>>;
|
|
403
|
-
create(overrides?: FactoryAttributes<TModel>): Promise<Entity<TModel['definition']['table']> | Array<Entity<TModel['definition']['table']>>>;
|
|
404
|
-
makeOne(sequence?: number, overrides?: FactoryAttributes<TModel>): Promise<Entity<TModel['definition']['table']>>;
|
|
405
|
-
createOne(sequence?: number, overrides?: FactoryAttributes<TModel>): Promise<Entity<TModel['definition']['table']>>;
|
|
406
|
-
makeMany(amount?: number, overrides?: FactoryAttributes<TModel>): Promise<Array<Entity<TModel['definition']['table']>>>;
|
|
407
|
-
createMany(amount?: number, overrides?: FactoryAttributes<TModel>): Promise<Array<Entity<TModel['definition']['table']>>>;
|
|
408
|
-
private clone;
|
|
409
|
-
private resolveAttributes;
|
|
410
|
-
private runHooks;
|
|
411
|
-
private makeContext;
|
|
412
|
-
private getRepository;
|
|
413
|
-
private getRelationDefinition;
|
|
414
|
-
private getPreparedRelationNames;
|
|
415
|
-
private resolveSingleSource;
|
|
416
|
-
private resolveManySource;
|
|
417
|
-
private takeRecycledEntities;
|
|
418
|
-
private applyParentRelations;
|
|
419
|
-
private applyChildRelations;
|
|
420
|
-
private applyAttachedRelations;
|
|
421
|
-
private makeChildOverrides;
|
|
422
|
-
private makeMorphChildOverrides;
|
|
423
|
-
private attachPivotAccessor;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
declare class FactoryService {
|
|
427
|
-
private readonly factories;
|
|
428
|
-
register<TModel extends FactoryModelReference>(name: string, factory: Factory<TModel>): this;
|
|
429
|
-
get(name: string): Factory<FactoryModelReference> | undefined;
|
|
430
|
-
has(name: string): boolean;
|
|
431
|
-
list(): readonly Factory<FactoryModelReference>[];
|
|
432
|
-
clear(): void;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
type ColumnMetadata = {
|
|
436
|
-
kind: LogicalColumnKind;
|
|
437
|
-
name?: string;
|
|
438
|
-
nullable: boolean;
|
|
439
|
-
hasDefault: boolean;
|
|
440
|
-
generated: boolean;
|
|
441
|
-
primaryKey: boolean;
|
|
442
|
-
unique: boolean;
|
|
443
|
-
defaultKind?: ColumnDefaultKind;
|
|
444
|
-
defaultValue?: unknown;
|
|
445
|
-
references?: ForeignKeyReference;
|
|
446
|
-
referenceTable?: string;
|
|
447
|
-
inferReferenceTable?: boolean;
|
|
448
|
-
referenceColumn?: string;
|
|
449
|
-
referenceConstraintName?: string;
|
|
450
|
-
referenceOnDelete?: ForeignKeyReference['onDelete'];
|
|
451
|
-
referenceOnUpdate?: ForeignKeyReference['onUpdate'];
|
|
452
|
-
idStrategy?: IdGenerationStrategy;
|
|
453
|
-
enumValues?: readonly string[];
|
|
454
|
-
vectorDimensions?: number;
|
|
455
|
-
};
|
|
456
|
-
type VectorOptions = {
|
|
457
|
-
dimensions: number;
|
|
458
|
-
};
|
|
459
|
-
type ColumnBuildOptions = {
|
|
460
|
-
name: string;
|
|
461
|
-
};
|
|
462
|
-
declare class ColumnBuilder<TType, TNullable extends boolean = false, THasDefault extends boolean = false, TGenerated extends boolean = false, TPrimaryKey extends boolean = false> {
|
|
463
|
-
private readonly metadata;
|
|
464
|
-
constructor(kind: LogicalColumnKind, name?: string, metadata?: Partial<ColumnMetadata>);
|
|
465
|
-
notNull(): ColumnBuilder<TType, false, THasDefault, TGenerated, TPrimaryKey>;
|
|
466
|
-
nullable(): ColumnBuilder<TType, true, THasDefault, TGenerated, TPrimaryKey>;
|
|
467
|
-
default(value: unknown): ColumnBuilder<TType, TNullable, true, TGenerated, TPrimaryKey>;
|
|
468
|
-
defaultNow(): ColumnBuilder<TType, TNullable, true, TGenerated, TPrimaryKey>;
|
|
469
|
-
generated(): ColumnBuilder<TType, TNullable, THasDefault, true, TPrimaryKey>;
|
|
470
|
-
primaryKey(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, true>;
|
|
471
|
-
unique(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
472
|
-
references(columnName: string): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
473
|
-
on(table: string): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
474
|
-
constraintName(name: string): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
475
|
-
constrained(table?: string, columnName?: string): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
476
|
-
onDelete(action: NonNullable<ForeignKeyReference['onDelete']>): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
477
|
-
onUpdate(action: NonNullable<ForeignKeyReference['onUpdate']>): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
478
|
-
cascadeOnDelete(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
479
|
-
restrictOnDelete(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
480
|
-
nullOnDelete(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
481
|
-
noActionOnDelete(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
482
|
-
cascadeOnUpdate(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
483
|
-
restrictOnUpdate(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
484
|
-
nullOnUpdate(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
485
|
-
noActionOnUpdate(): ColumnBuilder<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
486
|
-
toDefinition(options: ColumnBuildOptions): ColumnDefinition<TType, TNullable, THasDefault, TGenerated, TPrimaryKey>;
|
|
487
|
-
private clone;
|
|
488
|
-
}
|
|
489
|
-
declare const column: {
|
|
490
|
-
id(name?: string): ColumnBuilder<number, false, false, true, true>;
|
|
491
|
-
autoIncrementId(name?: string): ColumnBuilder<number, false, false, true, true>;
|
|
492
|
-
integer(name?: string): ColumnBuilder<number, false, false, false, false>;
|
|
493
|
-
bigInteger(name?: string): ColumnBuilder<number, false, false, false, false>;
|
|
494
|
-
string(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
495
|
-
text(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
496
|
-
boolean(name?: string): ColumnBuilder<boolean, false, false, false, false>;
|
|
497
|
-
real(name?: string): ColumnBuilder<number, false, false, false, false>;
|
|
498
|
-
decimal(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
499
|
-
date(name?: string): ColumnBuilder<Date, false, false, false, false>;
|
|
500
|
-
datetime(name?: string): ColumnBuilder<Date, false, false, false, false>;
|
|
501
|
-
timestamp(name?: string): ColumnBuilder<Date, false, false, false, false>;
|
|
502
|
-
json<TValue = unknown>(name?: string): ColumnBuilder<TValue, false, false, false, false>;
|
|
503
|
-
blob(name?: string): ColumnBuilder<Uint8Array<ArrayBufferLike>, false, false, false, false>;
|
|
504
|
-
uuid(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
505
|
-
ulid(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
506
|
-
snowflake(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
507
|
-
foreignId(name?: string): ColumnBuilder<number, false, false, false, false>;
|
|
508
|
-
foreignUuid(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
509
|
-
foreignUlid(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
510
|
-
foreignSnowflake(name?: string): ColumnBuilder<string, false, false, false, false>;
|
|
511
|
-
vector(options: VectorOptions, name?: string): ColumnBuilder<VectorValue, false, false, false, false>;
|
|
512
|
-
enum<const TValues extends readonly string[]>(values: TValues, name?: string): ColumnBuilder<TValues[number], false, false, false, false>;
|
|
513
|
-
};
|
|
514
|
-
type AnyColumnBuilder = ColumnBuilder<unknown, boolean, boolean, boolean, boolean>;
|
|
515
|
-
type ColumnInput = AnyColumnBuilder | AnyColumnDefinition;
|
|
516
|
-
|
|
517
|
-
type ColumnShapeInput$1 = Record<string, ColumnInput>;
|
|
518
|
-
type ResolvedColumn<TColumn extends ColumnInput> = TColumn extends {
|
|
519
|
-
toDefinition(options: {
|
|
520
|
-
name: string;
|
|
521
|
-
}): infer TDefinition;
|
|
522
|
-
} ? TDefinition extends AnyColumnDefinition ? TDefinition : never : TColumn extends AnyColumnDefinition ? TColumn : never;
|
|
523
|
-
type BoundColumns<TColumns extends ColumnShapeInput$1> = {
|
|
524
|
-
[K in keyof TColumns]: ResolvedColumn<TColumns[K]>;
|
|
525
|
-
};
|
|
526
|
-
type BoundTableDefinition<TName extends string, TColumns extends ColumnShapeInput$1> = TableDefinition<TName, BoundColumns<TColumns>> & BoundColumns<TColumns>;
|
|
527
|
-
|
|
528
|
-
declare class ForeignKeyBuilderState {
|
|
529
|
-
private readonly columnName;
|
|
530
|
-
private referenceTable?;
|
|
531
|
-
private referenceColumn;
|
|
532
|
-
private onDeleteAction?;
|
|
533
|
-
private onUpdateAction?;
|
|
534
|
-
constructor(columnName: string, referenceColumn?: string);
|
|
535
|
-
references(columnName: string): void;
|
|
536
|
-
on(table: string): void;
|
|
537
|
-
constrained(table?: string, columnName?: string): void;
|
|
538
|
-
onDelete(action: NonNullable<ForeignKeyReference['onDelete']>): void;
|
|
539
|
-
onUpdate(action: NonNullable<ForeignKeyReference['onUpdate']>): void;
|
|
540
|
-
toReference(defaultTable?: string): ForeignKeyReference;
|
|
541
|
-
applyToColumnBuilder(builder: AnyColumnBuilder): AnyColumnBuilder;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
type ColumnShapeInput = Record<string, ColumnInput>;
|
|
545
|
-
type WithColumn<TColumns extends ColumnShapeInput, TColumnName extends string, TColumn extends ColumnInput> = TColumns & {
|
|
546
|
-
[K in TColumnName]: TColumn;
|
|
547
|
-
};
|
|
548
|
-
type TimestampColumn = ReturnType<typeof column.timestamp>;
|
|
549
|
-
type NullableTimestampColumn = ReturnType<ReturnType<typeof column.timestamp>['nullable']>;
|
|
550
|
-
type StringColumn = ReturnType<typeof column.string>;
|
|
551
|
-
type NullableStringColumn = ReturnType<ReturnType<typeof column.string>['nullable']>;
|
|
552
|
-
type WithTimestamps<TColumns extends ColumnShapeInput> = TColumns & {
|
|
553
|
-
created_at: TimestampColumn;
|
|
554
|
-
updated_at: TimestampColumn;
|
|
555
|
-
};
|
|
556
|
-
type WithSoftDeletes<TColumns extends ColumnShapeInput, TColumnName extends string> = TColumns & {
|
|
557
|
-
[K in TColumnName]: NullableTimestampColumn;
|
|
558
|
-
};
|
|
559
|
-
type WithMorphColumns<TColumns extends ColumnShapeInput, TMorphName extends string, TIdColumn extends AnyColumnBuilder> = TColumns & {
|
|
560
|
-
[K in `${TMorphName}_type`]: StringColumn;
|
|
561
|
-
} & {
|
|
562
|
-
[K in `${TMorphName}_id`]: TIdColumn;
|
|
563
|
-
};
|
|
564
|
-
type WithNullableMorphColumns<TColumns extends ColumnShapeInput, TMorphName extends string, TIdColumn extends AnyColumnBuilder> = TColumns & {
|
|
565
|
-
[K in `${TMorphName}_type`]: NullableStringColumn;
|
|
566
|
-
} & {
|
|
567
|
-
[K in `${TMorphName}_id`]: ReturnType<TIdColumn['nullable']>;
|
|
568
|
-
};
|
|
569
|
-
type ColumnReference$1 = {
|
|
570
|
-
builder: AnyColumnBuilder;
|
|
571
|
-
};
|
|
572
|
-
declare class TableCreateColumnBuilder<TName extends string, TColumns extends ColumnShapeInput> {
|
|
573
|
-
protected readonly root: TableDefinitionBuilder<TName, TColumns>;
|
|
574
|
-
protected readonly builderRef: ColumnReference$1;
|
|
575
|
-
protected readonly columnName: string;
|
|
576
|
-
constructor(root: TableDefinitionBuilder<TName, TColumns>, builderRef: ColumnReference$1, columnName: string);
|
|
577
|
-
build(): BoundTableDefinition<TName, TColumns>;
|
|
578
|
-
notNull(): this;
|
|
579
|
-
nullable(): this;
|
|
580
|
-
default(value: unknown): this;
|
|
581
|
-
defaultNow(): this;
|
|
582
|
-
generated(): this;
|
|
583
|
-
primaryKey(): this;
|
|
584
|
-
unique(): this;
|
|
585
|
-
unique(columns: readonly string[], name?: string): TableDefinitionBuilder<TName, TColumns>;
|
|
586
|
-
index(): this;
|
|
587
|
-
index(name: string): this;
|
|
588
|
-
index(columns: readonly string[], name?: string): TableDefinitionBuilder<TName, TColumns>;
|
|
589
|
-
foreign(columnName: string): TableCreateForeignKeyBuilder<TName, TColumns>;
|
|
590
|
-
foreignId<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.bigInteger>>>;
|
|
591
|
-
foreignUuid<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.uuid>>>;
|
|
592
|
-
foreignUlid<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.ulid>>>;
|
|
593
|
-
foreignSnowflake<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.snowflake>>>;
|
|
594
|
-
id<TColumnName extends string = 'id'>(columnName?: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.id>>>;
|
|
595
|
-
autoIncrementId<TColumnName extends string = 'id'>(columnName?: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.autoIncrementId>>>;
|
|
596
|
-
integer<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.integer>>>;
|
|
597
|
-
bigInteger<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.bigInteger>>>;
|
|
598
|
-
string<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.string>>>;
|
|
599
|
-
text<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.text>>>;
|
|
600
|
-
boolean<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.boolean>>>;
|
|
601
|
-
real<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.real>>>;
|
|
602
|
-
decimal<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.decimal>>>;
|
|
603
|
-
date<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.date>>>;
|
|
604
|
-
datetime<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.datetime>>>;
|
|
605
|
-
timestamp<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.timestamp>>>;
|
|
606
|
-
json<TColumnName extends string, TValue = unknown>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.json<TValue>>>>;
|
|
607
|
-
blob<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.blob>>>;
|
|
608
|
-
uuid<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.uuid>>>;
|
|
609
|
-
ulid<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.ulid>>>;
|
|
610
|
-
snowflake<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.snowflake>>>;
|
|
611
|
-
vector<TColumnName extends string>(columnName: TColumnName, options: {
|
|
612
|
-
dimensions: number;
|
|
613
|
-
}): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.vector>>>;
|
|
614
|
-
enum<const TValues extends readonly string[], TColumnName extends string>(columnName: TColumnName, values: TValues): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.enum<TValues>>>>;
|
|
615
|
-
timestamps(): TableDefinitionBuilder<TName, WithTimestamps<TColumns>>;
|
|
616
|
-
softDeletes<TColumnName extends string = 'deleted_at'>(columnName?: TColumnName): TableDefinitionBuilder<TName, WithSoftDeletes<TColumns, TColumnName>>;
|
|
617
|
-
morphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.bigInteger>>>;
|
|
618
|
-
nullableMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.bigInteger>>>;
|
|
619
|
-
uuidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.uuid>>>;
|
|
620
|
-
nullableUuidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.uuid>>>;
|
|
621
|
-
ulidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.ulid>>>;
|
|
622
|
-
nullableUlidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.ulid>>>;
|
|
623
|
-
snowflakeMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.snowflake>>>;
|
|
624
|
-
nullableSnowflakeMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.snowflake>>>;
|
|
625
|
-
}
|
|
626
|
-
declare class TableCreateForeignIdBuilder<TName extends string, TColumns extends ColumnShapeInput> extends TableCreateColumnBuilder<TName, TColumns> {
|
|
627
|
-
private readonly foreignKeyState;
|
|
628
|
-
constructor(root: TableDefinitionBuilder<TName, TColumns>, builderRef: ColumnReference$1, columnName: string);
|
|
629
|
-
references(columnName: string): this;
|
|
630
|
-
on(table: string): this;
|
|
631
|
-
constrained(table?: string, columnName?: string): this;
|
|
632
|
-
onDelete(action: Parameters<ForeignKeyBuilderState['onDelete']>[0]): this;
|
|
633
|
-
onUpdate(action: Parameters<ForeignKeyBuilderState['onUpdate']>[0]): this;
|
|
634
|
-
cascadeOnDelete(): this;
|
|
635
|
-
restrictOnDelete(): this;
|
|
636
|
-
nullOnDelete(): this;
|
|
637
|
-
noActionOnDelete(): this;
|
|
638
|
-
cascadeOnUpdate(): this;
|
|
639
|
-
restrictOnUpdate(): this;
|
|
640
|
-
nullOnUpdate(): this;
|
|
641
|
-
noActionOnUpdate(): this;
|
|
642
|
-
private applyReference;
|
|
643
|
-
}
|
|
644
|
-
declare class TableCreateForeignKeyBuilder<TName extends string, TColumns extends ColumnShapeInput> {
|
|
645
|
-
private readonly root;
|
|
646
|
-
private readonly builderRef;
|
|
647
|
-
private readonly foreignKeyState;
|
|
648
|
-
constructor(root: TableDefinitionBuilder<TName, TColumns>, builderRef: ColumnReference$1, columnName: string);
|
|
649
|
-
references(columnName: string): this;
|
|
650
|
-
on(table: string): this;
|
|
651
|
-
constrained(table?: string, columnName?: string): this;
|
|
652
|
-
onDelete(action: Parameters<ForeignKeyBuilderState['onDelete']>[0]): this;
|
|
653
|
-
onUpdate(action: Parameters<ForeignKeyBuilderState['onUpdate']>[0]): this;
|
|
654
|
-
cascadeOnDelete(): this;
|
|
655
|
-
restrictOnDelete(): this;
|
|
656
|
-
nullOnDelete(): this;
|
|
657
|
-
noActionOnDelete(): this;
|
|
658
|
-
cascadeOnUpdate(): this;
|
|
659
|
-
restrictOnUpdate(): this;
|
|
660
|
-
nullOnUpdate(): this;
|
|
661
|
-
noActionOnUpdate(): this;
|
|
662
|
-
build(): BoundTableDefinition<TName, TColumns>;
|
|
663
|
-
private applyReference;
|
|
664
|
-
}
|
|
665
|
-
declare class TableDefinitionBuilder<TName extends string, TColumns extends ColumnShapeInput = Record<never, never>> {
|
|
666
|
-
readonly tableName: TName;
|
|
667
|
-
private readonly columns;
|
|
668
|
-
private readonly columnRefs;
|
|
669
|
-
private readonly indexes;
|
|
670
|
-
constructor(tableName: TName);
|
|
671
|
-
build(): BoundTableDefinition<TName, TColumns>;
|
|
672
|
-
id<TColumnName extends string = 'id'>(columnName?: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.id>>>;
|
|
673
|
-
autoIncrementId<TColumnName extends string = 'id'>(columnName?: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.autoIncrementId>>>;
|
|
674
|
-
integer<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.integer>>>;
|
|
675
|
-
bigInteger<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.bigInteger>>>;
|
|
676
|
-
foreignId<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.bigInteger>>>;
|
|
677
|
-
foreignUuid<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.uuid>>>;
|
|
678
|
-
foreignUlid<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.ulid>>>;
|
|
679
|
-
foreignSnowflake<TColumnName extends string>(columnName: TColumnName): TableCreateForeignIdBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.snowflake>>>;
|
|
680
|
-
string<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.string>>>;
|
|
681
|
-
text<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.text>>>;
|
|
682
|
-
boolean<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.boolean>>>;
|
|
683
|
-
real<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.real>>>;
|
|
684
|
-
decimal<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.decimal>>>;
|
|
685
|
-
date<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.date>>>;
|
|
686
|
-
datetime<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.datetime>>>;
|
|
687
|
-
timestamp<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.timestamp>>>;
|
|
688
|
-
json<TColumnName extends string, TValue = unknown>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.json<TValue>>>>;
|
|
689
|
-
blob<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.blob>>>;
|
|
690
|
-
uuid<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.uuid>>>;
|
|
691
|
-
ulid<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.ulid>>>;
|
|
692
|
-
snowflake<TColumnName extends string>(columnName: TColumnName): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.snowflake>>>;
|
|
693
|
-
vector<TColumnName extends string>(columnName: TColumnName, options: {
|
|
694
|
-
dimensions: number;
|
|
695
|
-
}): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.vector>>>;
|
|
696
|
-
enum<const TValues extends readonly string[], TColumnName extends string>(columnName: TColumnName, values: TValues): TableCreateColumnBuilder<TName, WithColumn<TColumns, TColumnName, ReturnType<typeof column.enum<TValues>>>>;
|
|
697
|
-
index(columns: readonly string[], name?: string): this;
|
|
698
|
-
unique(columns: readonly string[], name?: string): this;
|
|
699
|
-
foreign(columnName: string): TableCreateForeignKeyBuilder<TName, TColumns>;
|
|
700
|
-
timestamps(): TableDefinitionBuilder<TName, WithTimestamps<TColumns>>;
|
|
701
|
-
softDeletes<TColumnName extends string = 'deleted_at'>(columnName?: TColumnName): TableDefinitionBuilder<TName, WithSoftDeletes<TColumns, TColumnName>>;
|
|
702
|
-
morphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.bigInteger>>>;
|
|
703
|
-
nullableMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.bigInteger>>>;
|
|
704
|
-
uuidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.uuid>>>;
|
|
705
|
-
nullableUuidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.uuid>>>;
|
|
706
|
-
ulidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.ulid>>>;
|
|
707
|
-
nullableUlidMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.ulid>>>;
|
|
708
|
-
snowflakeMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithMorphColumns<TColumns, TMorphName, ReturnType<typeof column.snowflake>>>;
|
|
709
|
-
nullableSnowflakeMorphs<TMorphName extends string>(name: TMorphName, indexName?: string): TableDefinitionBuilder<TName, WithNullableMorphColumns<TColumns, TMorphName, ReturnType<typeof column.snowflake>>>;
|
|
710
|
-
private column;
|
|
711
|
-
private foreignColumn;
|
|
712
|
-
private applyMorphColumns;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
interface AddColumnMutationOperation {
|
|
716
|
-
kind: 'addColumn';
|
|
717
|
-
columnName: string;
|
|
718
|
-
column: AnyColumnBuilder;
|
|
719
|
-
}
|
|
720
|
-
interface AlterColumnMutationOperation {
|
|
721
|
-
kind: 'alterColumn';
|
|
722
|
-
columnName: string;
|
|
723
|
-
column: AnyColumnBuilder;
|
|
724
|
-
}
|
|
725
|
-
interface DropColumnMutationOperation {
|
|
726
|
-
kind: 'dropColumn';
|
|
727
|
-
columnName: string;
|
|
728
|
-
}
|
|
729
|
-
interface RenameColumnMutationOperation {
|
|
730
|
-
kind: 'renameColumn';
|
|
731
|
-
fromColumnName: string;
|
|
732
|
-
toColumnName: string;
|
|
733
|
-
}
|
|
734
|
-
interface CreateIndexMutationOperation {
|
|
735
|
-
kind: 'createIndex';
|
|
736
|
-
index: TableIndexDefinition;
|
|
737
|
-
}
|
|
738
|
-
interface DropIndexMutationOperation {
|
|
739
|
-
kind: 'dropIndex';
|
|
740
|
-
indexName: string;
|
|
741
|
-
}
|
|
742
|
-
interface RenameIndexMutationOperation {
|
|
743
|
-
kind: 'renameIndex';
|
|
744
|
-
fromIndexName: string;
|
|
745
|
-
toIndexName: string;
|
|
746
|
-
}
|
|
747
|
-
interface CreateForeignKeyMutationOperation {
|
|
748
|
-
kind: 'createForeignKey';
|
|
749
|
-
columnName: string;
|
|
750
|
-
reference: ForeignKeyReference;
|
|
751
|
-
constraintName?: string;
|
|
752
|
-
}
|
|
753
|
-
interface DropForeignKeyMutationOperation {
|
|
754
|
-
kind: 'dropForeignKey';
|
|
755
|
-
constraintName: string;
|
|
756
|
-
}
|
|
757
|
-
interface MutableColumnMutationOperation {
|
|
758
|
-
kind: ColumnMutationMode;
|
|
759
|
-
columnName: string;
|
|
760
|
-
column: AnyColumnBuilder;
|
|
761
|
-
}
|
|
762
|
-
type TableMutationOperation = AddColumnMutationOperation | AlterColumnMutationOperation | DropColumnMutationOperation | RenameColumnMutationOperation | CreateIndexMutationOperation | DropIndexMutationOperation | RenameIndexMutationOperation | CreateForeignKeyMutationOperation | DropForeignKeyMutationOperation;
|
|
763
|
-
type ColumnMutationMode = 'addColumn' | 'alterColumn';
|
|
764
|
-
declare class TableForeignKeyBuilder {
|
|
765
|
-
private readonly operation;
|
|
766
|
-
private readonly foreignKeyState;
|
|
767
|
-
constructor(operation: CreateForeignKeyMutationOperation);
|
|
768
|
-
references(columnName: string): this;
|
|
769
|
-
on(table: string): this;
|
|
770
|
-
constrained(table?: string, columnName?: string): this;
|
|
771
|
-
onDelete(action: NonNullable<ForeignKeyReference['onDelete']>): this;
|
|
772
|
-
onUpdate(action: NonNullable<ForeignKeyReference['onUpdate']>): this;
|
|
773
|
-
cascadeOnDelete(): this;
|
|
774
|
-
restrictOnDelete(): this;
|
|
775
|
-
nullOnDelete(): this;
|
|
776
|
-
noActionOnDelete(): this;
|
|
777
|
-
cascadeOnUpdate(): this;
|
|
778
|
-
restrictOnUpdate(): this;
|
|
779
|
-
nullOnUpdate(): this;
|
|
780
|
-
noActionOnUpdate(): this;
|
|
781
|
-
private applyReference;
|
|
782
|
-
}
|
|
783
|
-
declare class TableColumnMutationBuilder {
|
|
784
|
-
protected readonly root: TableMutationBuilder;
|
|
785
|
-
protected readonly operation: MutableColumnMutationOperation;
|
|
786
|
-
constructor(root: TableMutationBuilder, operation: MutableColumnMutationOperation);
|
|
787
|
-
notNull(): this;
|
|
788
|
-
nullable(): this;
|
|
789
|
-
default(value: unknown): this;
|
|
790
|
-
defaultNow(): this;
|
|
791
|
-
generated(): this;
|
|
792
|
-
primaryKey(): this;
|
|
793
|
-
unique(): this;
|
|
794
|
-
index(name?: string): this;
|
|
795
|
-
foreignId(columnName: string): TableForeignIdMutationBuilder;
|
|
796
|
-
foreignUuid(columnName: string): TableForeignIdMutationBuilder;
|
|
797
|
-
foreignUlid(columnName: string): TableForeignIdMutationBuilder;
|
|
798
|
-
foreignSnowflake(columnName: string): TableForeignIdMutationBuilder;
|
|
799
|
-
change(): this;
|
|
800
|
-
morphs(name: string, indexName?: string): TableMutationBuilder;
|
|
801
|
-
nullableMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
802
|
-
uuidMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
803
|
-
nullableUuidMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
804
|
-
ulidMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
805
|
-
nullableUlidMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
806
|
-
snowflakeMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
807
|
-
nullableSnowflakeMorphs(name: string, indexName?: string): TableMutationBuilder;
|
|
808
|
-
}
|
|
809
|
-
declare class TableForeignIdMutationBuilder extends TableColumnMutationBuilder {
|
|
810
|
-
private readonly operations;
|
|
811
|
-
private readonly columnName;
|
|
812
|
-
private readonly foreignKeyState;
|
|
813
|
-
private foreignOperation?;
|
|
814
|
-
constructor(root: TableMutationBuilder, operation: MutableColumnMutationOperation, operations: TableMutationOperation[], columnName: string);
|
|
815
|
-
references(columnName: string): this;
|
|
816
|
-
on(table: string): this;
|
|
817
|
-
constrained(table?: string, columnName?: string): this;
|
|
818
|
-
onDelete(action: NonNullable<ForeignKeyReference['onDelete']>): this;
|
|
819
|
-
onUpdate(action: NonNullable<ForeignKeyReference['onUpdate']>): this;
|
|
820
|
-
cascadeOnDelete(): this;
|
|
821
|
-
restrictOnDelete(): this;
|
|
822
|
-
nullOnDelete(): this;
|
|
823
|
-
noActionOnDelete(): this;
|
|
824
|
-
cascadeOnUpdate(): this;
|
|
825
|
-
restrictOnUpdate(): this;
|
|
826
|
-
nullOnUpdate(): this;
|
|
827
|
-
noActionOnUpdate(): this;
|
|
828
|
-
private applyForeignKey;
|
|
829
|
-
private ensureForeignOperation;
|
|
830
|
-
}
|
|
831
|
-
declare class TableMutationBuilder {
|
|
832
|
-
readonly table: string;
|
|
833
|
-
private readonly operations;
|
|
834
|
-
constructor(table: string);
|
|
835
|
-
getOperations(): readonly TableMutationOperation[];
|
|
836
|
-
id(columnName: string): TableColumnMutationBuilder;
|
|
837
|
-
autoIncrementId(columnName: string): TableColumnMutationBuilder;
|
|
838
|
-
integer(columnName: string): TableColumnMutationBuilder;
|
|
839
|
-
bigInteger(columnName: string): TableColumnMutationBuilder;
|
|
840
|
-
foreignId(columnName: string): TableForeignIdMutationBuilder;
|
|
841
|
-
foreignUuid(columnName: string): TableForeignIdMutationBuilder;
|
|
842
|
-
foreignUlid(columnName: string): TableForeignIdMutationBuilder;
|
|
843
|
-
foreignSnowflake(columnName: string): TableForeignIdMutationBuilder;
|
|
844
|
-
string(columnName: string): TableColumnMutationBuilder;
|
|
845
|
-
text(columnName: string): TableColumnMutationBuilder;
|
|
846
|
-
boolean(columnName: string): TableColumnMutationBuilder;
|
|
847
|
-
real(columnName: string): TableColumnMutationBuilder;
|
|
848
|
-
decimal(columnName: string): TableColumnMutationBuilder;
|
|
849
|
-
date(columnName: string): TableColumnMutationBuilder;
|
|
850
|
-
datetime(columnName: string): TableColumnMutationBuilder;
|
|
851
|
-
timestamp(columnName: string): TableColumnMutationBuilder;
|
|
852
|
-
json<TValue = unknown>(columnName: string): TableColumnMutationBuilder;
|
|
853
|
-
blob(columnName: string): TableColumnMutationBuilder;
|
|
854
|
-
uuid(columnName: string): TableColumnMutationBuilder;
|
|
855
|
-
ulid(columnName: string): TableColumnMutationBuilder;
|
|
856
|
-
snowflake(columnName: string): TableColumnMutationBuilder;
|
|
857
|
-
vector(columnName: string, options: {
|
|
858
|
-
dimensions: number;
|
|
859
|
-
}): TableColumnMutationBuilder;
|
|
860
|
-
enum<const TValues extends readonly string[]>(columnName: string, values: TValues): TableColumnMutationBuilder;
|
|
861
|
-
dropColumn(columnName: string): void;
|
|
862
|
-
renameColumn(fromColumnName: string, toColumnName: string): void;
|
|
863
|
-
index(columns: readonly string[], name?: string): void;
|
|
864
|
-
unique(columns: readonly string[], name?: string): void;
|
|
865
|
-
dropIndex(indexName: string): void;
|
|
866
|
-
renameIndex(fromIndexName: string, toIndexName: string): void;
|
|
867
|
-
foreign(columnName: string, constraintName?: string): TableForeignKeyBuilder;
|
|
868
|
-
dropForeign(indexName: string): void;
|
|
869
|
-
morphs(name: string, indexName?: string): this;
|
|
870
|
-
nullableMorphs(name: string, indexName?: string): this;
|
|
871
|
-
uuidMorphs(name: string, indexName?: string): this;
|
|
872
|
-
nullableUuidMorphs(name: string, indexName?: string): this;
|
|
873
|
-
ulidMorphs(name: string, indexName?: string): this;
|
|
874
|
-
nullableUlidMorphs(name: string, indexName?: string): this;
|
|
875
|
-
snowflakeMorphs(name: string, indexName?: string): this;
|
|
876
|
-
nullableSnowflakeMorphs(name: string, indexName?: string): this;
|
|
877
|
-
private columnMutation;
|
|
878
|
-
private foreignColumn;
|
|
879
|
-
private applyMorphColumns;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
interface IntrospectedColumn {
|
|
883
|
-
name: string;
|
|
884
|
-
type: string;
|
|
885
|
-
logicalType: LogicalColumnKind | null;
|
|
886
|
-
notNull: boolean;
|
|
887
|
-
defaultValue: string | null;
|
|
888
|
-
primaryKey: boolean;
|
|
889
|
-
}
|
|
890
|
-
interface IntrospectedIndex {
|
|
891
|
-
name: string;
|
|
892
|
-
unique: boolean;
|
|
893
|
-
columns: string[];
|
|
894
|
-
}
|
|
895
|
-
interface IntrospectedForeignKey {
|
|
896
|
-
table: string;
|
|
897
|
-
from: string;
|
|
898
|
-
to: string;
|
|
899
|
-
onUpdate: string;
|
|
900
|
-
onDelete: string;
|
|
901
|
-
}
|
|
902
|
-
interface SchemaSyncPlan {
|
|
903
|
-
readonly mode: 'create_missing_only';
|
|
904
|
-
readonly tablesToCreate: readonly string[];
|
|
905
|
-
readonly existingTables: readonly string[];
|
|
906
|
-
readonly destructiveChanges: false;
|
|
907
|
-
}
|
|
908
|
-
declare class SchemaService {
|
|
909
|
-
private readonly connection;
|
|
910
|
-
constructor(connection: DatabaseContext);
|
|
911
|
-
getDialectName(): string;
|
|
912
|
-
register<TTable extends TableDefinition>(table: TTable): TTable;
|
|
913
|
-
createTable<TName extends string>(tableName: TName, callback: (table: TableDefinitionBuilder<TName>) => void | Promise<void>): Promise<void>;
|
|
914
|
-
dropTable(tableName: string): Promise<void>;
|
|
915
|
-
renameTable(fromTableName: string, toTableName: string): Promise<void>;
|
|
916
|
-
table(tableName: string, callback: (table: TableMutationBuilder) => void | Promise<void>): Promise<void>;
|
|
917
|
-
enableForeignKeyConstraints(): Promise<void>;
|
|
918
|
-
disableForeignKeyConstraints(): Promise<void>;
|
|
919
|
-
withoutForeignKeyConstraints<TResult>(callback: () => TResult | Promise<TResult>): Promise<TResult>;
|
|
920
|
-
sync(tables?: readonly TableDefinition[]): Promise<void>;
|
|
921
|
-
previewSync(tables?: readonly TableDefinition[]): Promise<SchemaSyncPlan>;
|
|
922
|
-
hasTable(name: string): Promise<boolean>;
|
|
923
|
-
getTables(): Promise<string[]>;
|
|
924
|
-
getColumns(tableName: string): Promise<IntrospectedColumn[]>;
|
|
925
|
-
getIndexes(tableName: string): Promise<IntrospectedIndex[]>;
|
|
926
|
-
getForeignKeys(tableName: string): Promise<IntrospectedForeignKey[]>;
|
|
927
|
-
private createCompiler;
|
|
928
|
-
private execute;
|
|
929
|
-
private isSqlite;
|
|
930
|
-
private isPostgres;
|
|
931
|
-
private isMySQL;
|
|
932
|
-
private parsePostgresIndex;
|
|
933
|
-
private unsupportedIntrospectionError;
|
|
934
|
-
private assertAlterCapability;
|
|
935
|
-
private assertForeignKeyCapability;
|
|
936
|
-
private resolveColumnDefinition;
|
|
937
|
-
private createDefinedTable;
|
|
938
|
-
private assertTableMutationIndexNames;
|
|
939
|
-
private executeTableMutation;
|
|
940
|
-
private buildTableDefinition;
|
|
941
|
-
private updateRegisteredTable;
|
|
942
|
-
private renameRegisteredTable;
|
|
943
|
-
private withColumn;
|
|
944
|
-
private withAlteredColumn;
|
|
945
|
-
private withoutColumn;
|
|
946
|
-
private renameRegisteredColumn;
|
|
947
|
-
private withIndex;
|
|
948
|
-
private withoutIndex;
|
|
949
|
-
private renameRegisteredIndex;
|
|
950
|
-
private withForeignKey;
|
|
951
|
-
private withoutForeignKey;
|
|
952
|
-
private resolveIndexName;
|
|
953
|
-
private resolveForeignKeyName;
|
|
954
|
-
private createForeignKeyConstraintStatement;
|
|
955
|
-
private inferLogicalColumnType;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
interface MigrationContext {
|
|
959
|
-
readonly db: DatabaseContext;
|
|
960
|
-
readonly schema: SchemaService;
|
|
961
|
-
}
|
|
962
|
-
interface MigrationDefinition {
|
|
963
|
-
readonly name?: string;
|
|
964
|
-
up(context: MigrationContext): unknown | Promise<unknown>;
|
|
965
|
-
down?(context: MigrationContext): unknown | Promise<unknown>;
|
|
966
|
-
}
|
|
967
|
-
interface MigrationStatus {
|
|
968
|
-
readonly name: string;
|
|
969
|
-
readonly status: 'pending' | 'ran';
|
|
970
|
-
readonly batch?: number;
|
|
971
|
-
readonly migratedAt?: Date;
|
|
972
|
-
}
|
|
973
|
-
interface MigrationSquashPlan {
|
|
974
|
-
readonly archiveName: string;
|
|
975
|
-
readonly includedMigrations: readonly string[];
|
|
976
|
-
readonly fromBatch?: number;
|
|
977
|
-
readonly toBatch?: number;
|
|
978
|
-
readonly ranCount: number;
|
|
979
|
-
}
|
|
980
|
-
interface MigrateOptions {
|
|
981
|
-
step?: number;
|
|
982
|
-
}
|
|
983
|
-
interface RollbackOptions {
|
|
984
|
-
step?: number;
|
|
985
|
-
batch?: number;
|
|
986
|
-
}
|
|
987
|
-
interface MigrationExecutionPolicy {
|
|
988
|
-
readonly mode: 'exclusive';
|
|
989
|
-
readonly scope: 'adapter';
|
|
990
|
-
readonly allowsConcurrentMigrations: false;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
type RegisteredMigrationDefinition = MigrationDefinition & {
|
|
994
|
-
readonly name: string;
|
|
995
|
-
};
|
|
996
|
-
declare class MigrationService {
|
|
997
|
-
private readonly connection;
|
|
998
|
-
private readonly migrations;
|
|
999
|
-
constructor(connection: DatabaseContext, migrations?: readonly MigrationDefinition[]);
|
|
1000
|
-
register(migration: MigrationDefinition): this;
|
|
1001
|
-
getMigrations(): readonly RegisteredMigrationDefinition[];
|
|
1002
|
-
getMigration(name: string): RegisteredMigrationDefinition | undefined;
|
|
1003
|
-
hasRan(name: string): Promise<boolean>;
|
|
1004
|
-
status(): Promise<MigrationStatus[]>;
|
|
1005
|
-
planSquash(archiveName?: string): Promise<MigrationSquashPlan>;
|
|
1006
|
-
migrate(options?: MigrateOptions): Promise<RegisteredMigrationDefinition[]>;
|
|
1007
|
-
rollback(options?: RollbackOptions): Promise<RegisteredMigrationDefinition[]>;
|
|
1008
|
-
getExecutionPolicy(): MigrationExecutionPolicy;
|
|
1009
|
-
private ensureTrackingTable;
|
|
1010
|
-
private getRanRecords;
|
|
1011
|
-
private createContext;
|
|
1012
|
-
private runMigrationLifecycle;
|
|
1013
|
-
private normalizeMigratedAt;
|
|
1014
|
-
private createMigrationLog;
|
|
1015
|
-
private runExclusively;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
declare class ModelEventService {
|
|
1019
|
-
areEventsMuted(): boolean;
|
|
1020
|
-
withoutEvents<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
1021
|
-
areGuardsDisabled(): boolean;
|
|
1022
|
-
withoutGuards<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
interface SecurityPolicy {
|
|
1026
|
-
allowUnsafeRawSql: boolean;
|
|
1027
|
-
debugSqlInLogs: boolean;
|
|
1028
|
-
maxQueryComplexity?: number;
|
|
1029
|
-
redactBindingsInLogs: boolean;
|
|
1030
|
-
maxLoggedBindings: number;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
declare class SchemaRegistry {
|
|
1034
|
-
private readonly tables;
|
|
1035
|
-
register<TTable extends TableDefinition>(table: TTable): TTable;
|
|
1036
|
-
has(name: string): boolean;
|
|
1037
|
-
replace<TTable extends TableDefinition>(table: TTable): TTable;
|
|
1038
|
-
delete(name: string): void;
|
|
1039
|
-
get<TTable extends TableDefinition = TableDefinition>(name: string): TTable | undefined;
|
|
1040
|
-
list(): TableDefinition[];
|
|
1041
|
-
clear(): void;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
declare class ModelRegistry {
|
|
1045
|
-
private readonly models;
|
|
1046
|
-
register(reference: ModelDefinitionLike): AnyModelDefinition;
|
|
1047
|
-
has(name: string): boolean;
|
|
1048
|
-
get(name: string): AnyModelDefinition | undefined;
|
|
1049
|
-
list(): readonly AnyModelDefinition[];
|
|
1050
|
-
clear(): void;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
type SchedulingMode = 'concurrent' | 'serialized' | 'worker';
|
|
1054
|
-
interface QuerySchedulerOptions {
|
|
1055
|
-
connectionName: string;
|
|
1056
|
-
supportsConcurrentQueries: boolean;
|
|
1057
|
-
supportsWorkerThreads: boolean;
|
|
1058
|
-
concurrency?: ConcurrencyOptions;
|
|
1059
|
-
}
|
|
1060
|
-
declare class QueryScheduler {
|
|
1061
|
-
private readonly connectionName;
|
|
1062
|
-
private readonly queueLimit;
|
|
1063
|
-
private readonly supportsConcurrentQueries;
|
|
1064
|
-
private readonly supportsWorkerThreads;
|
|
1065
|
-
private readonly concurrentState;
|
|
1066
|
-
private readonly serializedState;
|
|
1067
|
-
private readonly workerState;
|
|
1068
|
-
constructor(options: QuerySchedulerOptions);
|
|
1069
|
-
schedule<T>(options: {
|
|
1070
|
-
transactional: boolean;
|
|
1071
|
-
preferWorkerThreads?: boolean;
|
|
1072
|
-
}, callback: (schedulingMode: SchedulingMode) => Promise<T>): Promise<{
|
|
1073
|
-
result: T;
|
|
1074
|
-
schedulingMode: SchedulingMode;
|
|
1075
|
-
}>;
|
|
1076
|
-
preview(options: {
|
|
1077
|
-
transactional: boolean;
|
|
1078
|
-
preferWorkerThreads?: boolean;
|
|
1079
|
-
}): SchedulingMode;
|
|
1080
|
-
private resolveMode;
|
|
1081
|
-
private resolveState;
|
|
1082
|
-
private waitForSlot;
|
|
1083
|
-
private wakeNext;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
type DatabaseDriverName = 'sqlite' | 'postgres' | 'mysql' | string;
|
|
1087
|
-
type TransactionScopeKind = 'root' | 'transaction' | 'savepoint';
|
|
1088
|
-
interface ConcurrencyOptions {
|
|
1089
|
-
maxConcurrentQueries?: number;
|
|
1090
|
-
queueLimit?: number;
|
|
1091
|
-
workerThreads?: boolean;
|
|
1092
|
-
}
|
|
1093
|
-
interface DatabaseOperationOptions {
|
|
1094
|
-
signal?: AbortSignal;
|
|
1095
|
-
timeoutMs?: number;
|
|
1096
|
-
}
|
|
1097
|
-
type TransactionCallback = () => void | Promise<void>;
|
|
1098
|
-
interface UnsafeStatement {
|
|
1099
|
-
unsafe: true;
|
|
1100
|
-
sql: string;
|
|
1101
|
-
bindings?: readonly unknown[];
|
|
1102
|
-
source?: string;
|
|
1103
|
-
}
|
|
1104
|
-
type CompiledQueryKind = 'select' | 'insert' | 'update' | 'upsert' | 'delete';
|
|
1105
|
-
type CompiledQueryResultMode = 'rows' | 'write';
|
|
1106
|
-
type CompiledQueryIntent = 'read' | 'write';
|
|
1107
|
-
type CompiledQueryStreamingMode = 'buffered';
|
|
1108
|
-
type CompiledQueryTransactionAffinity = 'optional' | 'required';
|
|
1109
|
-
interface CompiledStatementMetadata {
|
|
1110
|
-
kind: CompiledQueryKind;
|
|
1111
|
-
resultMode: CompiledQueryResultMode;
|
|
1112
|
-
selectedShape: {
|
|
1113
|
-
mode: 'all' | 'projection' | 'write';
|
|
1114
|
-
columns: readonly string[];
|
|
1115
|
-
aggregates: readonly string[];
|
|
1116
|
-
hasRawSelections: boolean;
|
|
1117
|
-
hasSubqueries: boolean;
|
|
1118
|
-
};
|
|
1119
|
-
safety: {
|
|
1120
|
-
unsafe: boolean;
|
|
1121
|
-
containsRawSql: boolean;
|
|
1122
|
-
};
|
|
1123
|
-
debug: {
|
|
1124
|
-
tableName: string;
|
|
1125
|
-
hasJoins: boolean;
|
|
1126
|
-
hasUnions: boolean;
|
|
1127
|
-
hasGrouping: boolean;
|
|
1128
|
-
hasHaving: boolean;
|
|
1129
|
-
complexity: number;
|
|
1130
|
-
lockMode?: string;
|
|
1131
|
-
intent: CompiledQueryIntent;
|
|
1132
|
-
transactionAffinity: CompiledQueryTransactionAffinity;
|
|
1133
|
-
streaming: CompiledQueryStreamingMode;
|
|
1134
|
-
connectionName?: string;
|
|
1135
|
-
scope?: TransactionScopeKind;
|
|
1136
|
-
schedulingMode?: SchedulingMode;
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
interface CompiledStatement {
|
|
1140
|
-
unsafe?: true;
|
|
1141
|
-
sql: string;
|
|
1142
|
-
bindings?: readonly unknown[];
|
|
1143
|
-
source?: string;
|
|
1144
|
-
metadata?: CompiledStatementMetadata;
|
|
1145
|
-
}
|
|
1146
|
-
interface DriverQueryResult<TRow extends Record<string, unknown> = Record<string, unknown>> {
|
|
1147
|
-
rows: TRow[];
|
|
1148
|
-
rowCount: number;
|
|
1149
|
-
}
|
|
1150
|
-
interface DriverExecutionResult {
|
|
1151
|
-
affectedRows?: number;
|
|
1152
|
-
lastInsertId?: number | string;
|
|
1153
|
-
}
|
|
1154
|
-
interface DriverAdapter {
|
|
1155
|
-
initialize(): Promise<void>;
|
|
1156
|
-
disconnect(): Promise<void>;
|
|
1157
|
-
isConnected(): boolean;
|
|
1158
|
-
runWithTransactionScope?<T>(callback: () => Promise<T>): Promise<T>;
|
|
1159
|
-
introspect?<TRow extends Record<string, unknown> = Record<string, unknown>>(sql: string, bindings?: readonly unknown[], options?: DatabaseOperationOptions): Promise<DriverQueryResult<TRow>>;
|
|
1160
|
-
query<TRow extends Record<string, unknown> = Record<string, unknown>>(sql: string, bindings?: readonly unknown[], options?: DatabaseOperationOptions): Promise<DriverQueryResult<TRow>>;
|
|
1161
|
-
execute(sql: string, bindings?: readonly unknown[], options?: DatabaseOperationOptions): Promise<DriverExecutionResult>;
|
|
1162
|
-
beginTransaction(options?: DatabaseOperationOptions): Promise<void>;
|
|
1163
|
-
commit(options?: DatabaseOperationOptions): Promise<void>;
|
|
1164
|
-
rollback(options?: DatabaseOperationOptions): Promise<void>;
|
|
1165
|
-
createSavepoint?(name: string, options?: DatabaseOperationOptions): Promise<void>;
|
|
1166
|
-
rollbackToSavepoint?(name: string, options?: DatabaseOperationOptions): Promise<void>;
|
|
1167
|
-
releaseSavepoint?(name: string, options?: DatabaseOperationOptions): Promise<void>;
|
|
1168
|
-
}
|
|
1169
|
-
interface Dialect {
|
|
1170
|
-
readonly name: string;
|
|
1171
|
-
readonly capabilities: DatabaseCapabilities;
|
|
1172
|
-
quoteIdentifier(identifier: string): string;
|
|
1173
|
-
createPlaceholder(index: number): string;
|
|
1174
|
-
}
|
|
1175
|
-
interface QueryStartLog {
|
|
1176
|
-
kind: 'query' | 'execute';
|
|
1177
|
-
connectionName: string;
|
|
1178
|
-
sql: string;
|
|
1179
|
-
bindings: unknown[];
|
|
1180
|
-
source?: string;
|
|
1181
|
-
scope: TransactionScopeKind;
|
|
1182
|
-
schedulingMode?: 'concurrent' | 'serialized' | 'worker';
|
|
1183
|
-
}
|
|
1184
|
-
interface QuerySuccessLog extends QueryStartLog {
|
|
1185
|
-
durationMs: number;
|
|
1186
|
-
rowCount?: number;
|
|
1187
|
-
affectedRows?: number;
|
|
1188
|
-
}
|
|
1189
|
-
interface QueryErrorLog extends QueryStartLog {
|
|
1190
|
-
durationMs: number;
|
|
1191
|
-
error: unknown;
|
|
1192
|
-
}
|
|
1193
|
-
interface TransactionLog {
|
|
1194
|
-
scope: Exclude<TransactionScopeKind, 'root'>;
|
|
1195
|
-
depth: number;
|
|
1196
|
-
savepointName?: string;
|
|
1197
|
-
}
|
|
1198
|
-
interface MigrationStartLog {
|
|
1199
|
-
connectionName: string;
|
|
1200
|
-
migrationName: string;
|
|
1201
|
-
action: 'up' | 'down';
|
|
1202
|
-
batch?: number;
|
|
1203
|
-
}
|
|
1204
|
-
interface MigrationSuccessLog extends MigrationStartLog {
|
|
1205
|
-
durationMs: number;
|
|
1206
|
-
}
|
|
1207
|
-
interface MigrationErrorLog extends MigrationStartLog {
|
|
1208
|
-
durationMs: number;
|
|
1209
|
-
error: unknown;
|
|
1210
|
-
}
|
|
1211
|
-
interface SeederStartLog {
|
|
1212
|
-
connectionName: string;
|
|
1213
|
-
seederName: string;
|
|
1214
|
-
quietly: boolean;
|
|
1215
|
-
environment?: string;
|
|
1216
|
-
}
|
|
1217
|
-
interface SeederSuccessLog extends SeederStartLog {
|
|
1218
|
-
durationMs: number;
|
|
1219
|
-
}
|
|
1220
|
-
interface SeederErrorLog extends SeederStartLog {
|
|
1221
|
-
durationMs: number;
|
|
1222
|
-
error: unknown;
|
|
1223
|
-
}
|
|
1224
|
-
interface DatabaseLogger {
|
|
1225
|
-
onQueryStart?(entry: QueryStartLog): void | Promise<void>;
|
|
1226
|
-
onQuerySuccess?(entry: QuerySuccessLog): void | Promise<void>;
|
|
1227
|
-
onQueryError?(entry: QueryErrorLog): void | Promise<void>;
|
|
1228
|
-
onTransactionStart?(entry: TransactionLog): void | Promise<void>;
|
|
1229
|
-
onTransactionCommit?(entry: TransactionLog): void | Promise<void>;
|
|
1230
|
-
onTransactionRollback?(entry: TransactionLog & {
|
|
1231
|
-
error?: unknown;
|
|
1232
|
-
}): void | Promise<void>;
|
|
1233
|
-
onMigrationStart?(entry: MigrationStartLog): void | Promise<void>;
|
|
1234
|
-
onMigrationSuccess?(entry: MigrationSuccessLog): void | Promise<void>;
|
|
1235
|
-
onMigrationError?(entry: MigrationErrorLog): void | Promise<void>;
|
|
1236
|
-
onSeederStart?(entry: SeederStartLog): void | Promise<void>;
|
|
1237
|
-
onSeederSuccess?(entry: SeederSuccessLog): void | Promise<void>;
|
|
1238
|
-
onSeederError?(entry: SeederErrorLog): void | Promise<void>;
|
|
1239
|
-
}
|
|
1240
|
-
interface DatabaseContextOptions {
|
|
1241
|
-
connectionName?: string;
|
|
1242
|
-
schemaName?: string;
|
|
1243
|
-
adapter: DriverAdapter;
|
|
1244
|
-
dialect: Dialect;
|
|
1245
|
-
driver?: DatabaseDriverName;
|
|
1246
|
-
logger?: DatabaseLogger;
|
|
1247
|
-
security?: Partial<SecurityPolicy>;
|
|
1248
|
-
concurrency?: ConcurrencyOptions;
|
|
1249
|
-
schemaRegistry?: SchemaRegistry;
|
|
1250
|
-
modelRegistry?: ModelRegistry;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
type QueryOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | 'not in' | 'between' | 'not between' | 'like';
|
|
1254
|
-
type QueryDirection = 'asc' | 'desc';
|
|
1255
|
-
type QueryLockMode = 'update' | 'share';
|
|
1256
|
-
type QueryJoinType = 'inner' | 'left' | 'right' | 'cross';
|
|
1257
|
-
interface QuerySource {
|
|
1258
|
-
readonly kind: 'table';
|
|
1259
|
-
readonly tableName: string;
|
|
1260
|
-
readonly alias?: string;
|
|
1261
|
-
readonly table?: TableDefinition;
|
|
1262
|
-
}
|
|
1263
|
-
interface QueryColumnSelection {
|
|
1264
|
-
readonly kind: 'column';
|
|
1265
|
-
readonly column: string;
|
|
1266
|
-
readonly alias?: string;
|
|
1267
|
-
}
|
|
1268
|
-
interface QueryAggregateSelection {
|
|
1269
|
-
readonly kind: 'aggregate';
|
|
1270
|
-
readonly aggregate: 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
1271
|
-
readonly column: string | '*';
|
|
1272
|
-
readonly alias: string;
|
|
1273
|
-
}
|
|
1274
|
-
interface QueryRawSelection {
|
|
1275
|
-
readonly kind: 'raw';
|
|
1276
|
-
readonly sql: string;
|
|
1277
|
-
readonly bindings: readonly unknown[];
|
|
1278
|
-
}
|
|
1279
|
-
interface QuerySubquerySelection {
|
|
1280
|
-
readonly kind: 'subquery';
|
|
1281
|
-
readonly query: SelectQueryPlan;
|
|
1282
|
-
readonly alias: string;
|
|
1283
|
-
}
|
|
1284
|
-
type QuerySelection = QueryColumnSelection | QueryAggregateSelection | QueryRawSelection | QuerySubquerySelection;
|
|
1285
|
-
interface QueryJoinClause {
|
|
1286
|
-
readonly type: QueryJoinType;
|
|
1287
|
-
readonly table?: string;
|
|
1288
|
-
readonly subquery?: SelectQueryPlan;
|
|
1289
|
-
readonly alias?: string;
|
|
1290
|
-
readonly lateral?: boolean;
|
|
1291
|
-
readonly leftColumn?: string;
|
|
1292
|
-
readonly operator?: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>;
|
|
1293
|
-
readonly rightColumn?: string;
|
|
1294
|
-
}
|
|
1295
|
-
interface QueryUnionClause {
|
|
1296
|
-
readonly all: boolean;
|
|
1297
|
-
readonly query: SelectQueryPlan;
|
|
1298
|
-
}
|
|
1299
|
-
interface QueryHavingClause {
|
|
1300
|
-
readonly expression: string;
|
|
1301
|
-
readonly operator: Exclude<QueryOperator, 'in' | 'not in'>;
|
|
1302
|
-
readonly value: unknown;
|
|
1303
|
-
}
|
|
1304
|
-
interface QueryPredicate {
|
|
1305
|
-
readonly kind: 'comparison';
|
|
1306
|
-
readonly boolean?: 'and' | 'or';
|
|
1307
|
-
readonly column: string;
|
|
1308
|
-
readonly operator: QueryOperator;
|
|
1309
|
-
readonly value: unknown;
|
|
1310
|
-
}
|
|
1311
|
-
interface QueryColumnPredicate {
|
|
1312
|
-
readonly kind: 'column';
|
|
1313
|
-
readonly boolean?: 'and' | 'or';
|
|
1314
|
-
readonly column: string;
|
|
1315
|
-
readonly operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>;
|
|
1316
|
-
readonly compareTo: string;
|
|
1317
|
-
}
|
|
1318
|
-
interface QueryNullPredicate {
|
|
1319
|
-
readonly kind: 'null';
|
|
1320
|
-
readonly boolean?: 'and' | 'or';
|
|
1321
|
-
readonly column: string;
|
|
1322
|
-
readonly negated: boolean;
|
|
1323
|
-
}
|
|
1324
|
-
type QueryDatePart = 'date' | 'month' | 'day' | 'year' | 'time';
|
|
1325
|
-
interface QueryDatePredicate {
|
|
1326
|
-
readonly kind: 'date';
|
|
1327
|
-
readonly boolean?: 'and' | 'or';
|
|
1328
|
-
readonly column: string;
|
|
1329
|
-
readonly part: QueryDatePart;
|
|
1330
|
-
readonly operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>;
|
|
1331
|
-
readonly value: unknown;
|
|
1332
|
-
}
|
|
1333
|
-
type QueryJsonMode = 'value' | 'contains' | 'length';
|
|
1334
|
-
type QueryFullTextMode = 'natural' | 'boolean';
|
|
1335
|
-
interface QueryJsonPredicate {
|
|
1336
|
-
readonly kind: 'json';
|
|
1337
|
-
readonly boolean?: 'and' | 'or';
|
|
1338
|
-
readonly column: string;
|
|
1339
|
-
readonly path: readonly string[];
|
|
1340
|
-
readonly jsonMode: QueryJsonMode;
|
|
1341
|
-
readonly operator?: Exclude<QueryOperator, 'in' | 'not in'>;
|
|
1342
|
-
readonly value: unknown;
|
|
1343
|
-
}
|
|
1344
|
-
interface QueryFullTextPredicate {
|
|
1345
|
-
readonly kind: 'fulltext';
|
|
1346
|
-
readonly boolean?: 'and' | 'or';
|
|
1347
|
-
readonly columns: readonly string[];
|
|
1348
|
-
readonly mode: QueryFullTextMode;
|
|
1349
|
-
readonly value: string;
|
|
1350
|
-
}
|
|
1351
|
-
interface QueryVectorPredicate {
|
|
1352
|
-
readonly kind: 'vector';
|
|
1353
|
-
readonly boolean?: 'and' | 'or';
|
|
1354
|
-
readonly column: string;
|
|
1355
|
-
readonly vector: readonly number[];
|
|
1356
|
-
readonly minSimilarity: number;
|
|
1357
|
-
}
|
|
1358
|
-
interface QueryGroupPredicate {
|
|
1359
|
-
readonly kind: 'group';
|
|
1360
|
-
readonly boolean?: 'and' | 'or';
|
|
1361
|
-
readonly negated?: boolean;
|
|
1362
|
-
readonly predicates: readonly QueryPredicateNode[];
|
|
1363
|
-
}
|
|
1364
|
-
interface QueryExistsPredicate {
|
|
1365
|
-
readonly kind: 'exists';
|
|
1366
|
-
readonly boolean?: 'and' | 'or';
|
|
1367
|
-
readonly negated?: boolean;
|
|
1368
|
-
readonly subquery: SelectQueryPlan;
|
|
1369
|
-
}
|
|
1370
|
-
interface QuerySubqueryPredicate {
|
|
1371
|
-
readonly kind: 'subquery';
|
|
1372
|
-
readonly boolean?: 'and' | 'or';
|
|
1373
|
-
readonly column: string;
|
|
1374
|
-
readonly operator: Exclude<QueryOperator, 'between' | 'not between'>;
|
|
1375
|
-
readonly subquery: SelectQueryPlan;
|
|
1376
|
-
}
|
|
1377
|
-
interface QueryRawPredicate {
|
|
1378
|
-
readonly kind: 'raw';
|
|
1379
|
-
readonly boolean?: 'and' | 'or';
|
|
1380
|
-
readonly sql: string;
|
|
1381
|
-
readonly bindings: readonly unknown[];
|
|
1382
|
-
}
|
|
1383
|
-
type QueryPredicateNode = QueryPredicate | QueryColumnPredicate | QueryNullPredicate | QueryDatePredicate | QueryJsonPredicate | QueryFullTextPredicate | QueryVectorPredicate | QueryGroupPredicate | QueryExistsPredicate | QuerySubqueryPredicate | QueryRawPredicate;
|
|
1384
|
-
type QueryOrderBy = {
|
|
1385
|
-
readonly kind: 'column';
|
|
1386
|
-
readonly column: string;
|
|
1387
|
-
readonly direction: QueryDirection;
|
|
1388
|
-
} | {
|
|
1389
|
-
readonly kind: 'vector';
|
|
1390
|
-
readonly column: string;
|
|
1391
|
-
readonly vector: readonly number[];
|
|
1392
|
-
} | {
|
|
1393
|
-
readonly kind: 'random';
|
|
1394
|
-
} | {
|
|
1395
|
-
readonly kind: 'raw';
|
|
1396
|
-
readonly sql: string;
|
|
1397
|
-
readonly bindings: readonly unknown[];
|
|
1398
|
-
};
|
|
1399
|
-
interface SelectQueryPlan {
|
|
1400
|
-
readonly kind: 'select';
|
|
1401
|
-
readonly source: QuerySource;
|
|
1402
|
-
readonly distinct: boolean;
|
|
1403
|
-
readonly selections: readonly QuerySelection[];
|
|
1404
|
-
readonly joins: readonly QueryJoinClause[];
|
|
1405
|
-
readonly unions: readonly QueryUnionClause[];
|
|
1406
|
-
readonly predicates: readonly QueryPredicateNode[];
|
|
1407
|
-
readonly groupBy: readonly string[];
|
|
1408
|
-
readonly having: readonly QueryHavingClause[];
|
|
1409
|
-
readonly orderBy: readonly QueryOrderBy[];
|
|
1410
|
-
readonly lockMode?: QueryLockMode;
|
|
1411
|
-
readonly limit?: number;
|
|
1412
|
-
readonly offset?: number;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
type QueryCacheTtlInput = number | Date;
|
|
1416
|
-
type QueryCacheFlexibleTtlInput = readonly [fresh: number, stale: number] | {
|
|
1417
|
-
readonly fresh: number;
|
|
1418
|
-
readonly stale: number;
|
|
1419
|
-
};
|
|
1420
|
-
interface QueryCacheConfig {
|
|
1421
|
-
readonly ttl?: QueryCacheTtlInput;
|
|
1422
|
-
readonly key?: string;
|
|
1423
|
-
readonly driver?: string;
|
|
1424
|
-
readonly flexible?: QueryCacheFlexibleTtlInput;
|
|
1425
|
-
readonly invalidate?: readonly string[];
|
|
1426
|
-
}
|
|
1427
|
-
interface NormalizedQueryCacheConfig extends QueryCacheConfig {
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
interface PaginationMeta {
|
|
1431
|
-
readonly total: number;
|
|
1432
|
-
readonly perPage: number;
|
|
1433
|
-
readonly pageName: string;
|
|
1434
|
-
readonly currentPage: number;
|
|
1435
|
-
readonly lastPage: number;
|
|
1436
|
-
readonly from: number | null;
|
|
1437
|
-
readonly to: number | null;
|
|
1438
|
-
readonly hasMorePages: boolean;
|
|
1439
|
-
}
|
|
1440
|
-
interface PaginatorMethods<T> {
|
|
1441
|
-
items(): readonly T[];
|
|
1442
|
-
firstItem(): number | null;
|
|
1443
|
-
lastItem(): number | null;
|
|
1444
|
-
hasPages(): boolean;
|
|
1445
|
-
hasMorePages(): boolean;
|
|
1446
|
-
getPageName(): string;
|
|
1447
|
-
toJSON(): {
|
|
1448
|
-
data: readonly T[];
|
|
1449
|
-
meta: PaginationMeta;
|
|
1450
|
-
};
|
|
1451
|
-
}
|
|
1452
|
-
interface SimplePaginationMeta {
|
|
1453
|
-
readonly perPage: number;
|
|
1454
|
-
readonly pageName: string;
|
|
1455
|
-
readonly currentPage: number;
|
|
1456
|
-
readonly from: number | null;
|
|
1457
|
-
readonly to: number | null;
|
|
1458
|
-
readonly hasMorePages: boolean;
|
|
1459
|
-
}
|
|
1460
|
-
interface SimplePaginatorMethods<T> {
|
|
1461
|
-
items(): readonly T[];
|
|
1462
|
-
firstItem(): number | null;
|
|
1463
|
-
lastItem(): number | null;
|
|
1464
|
-
hasPages(): boolean;
|
|
1465
|
-
hasMorePages(): boolean;
|
|
1466
|
-
getPageName(): string;
|
|
1467
|
-
toJSON(): {
|
|
1468
|
-
data: readonly T[];
|
|
1469
|
-
meta: SimplePaginationMeta;
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
interface PaginatedResult<T> extends PaginatorMethods<T> {
|
|
1473
|
-
readonly data: readonly T[];
|
|
1474
|
-
readonly meta: PaginationMeta;
|
|
1475
|
-
}
|
|
1476
|
-
interface SimplePaginatedResult<T> extends SimplePaginatorMethods<T> {
|
|
1477
|
-
readonly data: readonly T[];
|
|
1478
|
-
readonly meta: SimplePaginationMeta;
|
|
1479
|
-
}
|
|
1480
|
-
interface CursorPaginatorMethods<T> {
|
|
1481
|
-
items(): readonly T[];
|
|
1482
|
-
hasMorePages(): boolean;
|
|
1483
|
-
getCursorName(): string;
|
|
1484
|
-
nextCursorToken(): string | null;
|
|
1485
|
-
previousCursorToken(): string | null;
|
|
1486
|
-
toJSON(): {
|
|
1487
|
-
data: readonly T[];
|
|
1488
|
-
perPage: number;
|
|
1489
|
-
cursorName: string;
|
|
1490
|
-
nextCursor: string | null;
|
|
1491
|
-
prevCursor: string | null;
|
|
1492
|
-
};
|
|
1493
|
-
}
|
|
1494
|
-
interface CursorPaginatedResult<T> extends CursorPaginatorMethods<T> {
|
|
1495
|
-
readonly data: readonly T[];
|
|
1496
|
-
readonly perPage: number;
|
|
1497
|
-
readonly cursorName: string;
|
|
1498
|
-
readonly nextCursor: string | null;
|
|
1499
|
-
readonly prevCursor: string | null;
|
|
1500
|
-
}
|
|
1501
|
-
interface PaginationOptions {
|
|
1502
|
-
readonly pageName?: string;
|
|
1503
|
-
}
|
|
1504
|
-
interface CursorPaginationOptions {
|
|
1505
|
-
readonly cursorName?: string;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
type BuilderCallback$1<TBuilder> = (query: TBuilder) => unknown;
|
|
1509
|
-
type ValueBuilderCallback$1<TBuilder, TValue> = (query: TBuilder, value: TValue) => unknown;
|
|
1510
|
-
type RelationConstraint$1 = (query: ModelQueryBuilder<TableDefinition>) => unknown;
|
|
1511
|
-
type SubqueryBuilder<TSubTable extends TableDefinition = TableDefinition> = TableQueryBuilder<TSubTable, Record<string, unknown>> | ModelQueryBuilder<TSubTable>;
|
|
1512
|
-
type RelationFilter$1 = {
|
|
1513
|
-
relation: string;
|
|
1514
|
-
negate: boolean;
|
|
1515
|
-
constraint?: RelationConstraint$1;
|
|
1516
|
-
boolean?: 'and' | 'or';
|
|
1517
|
-
morphTypes?: readonly string[];
|
|
1518
|
-
};
|
|
1519
|
-
type MorphEntityTarget = {
|
|
1520
|
-
exists(): boolean;
|
|
1521
|
-
getRepository(): {
|
|
1522
|
-
definition: {
|
|
1523
|
-
morphClass: string;
|
|
1524
|
-
primaryKey: string;
|
|
1525
|
-
};
|
|
1526
|
-
};
|
|
1527
|
-
get(key: string): unknown;
|
|
1528
|
-
};
|
|
1529
|
-
type MorphModelTarget = {
|
|
1530
|
-
definition?: {
|
|
1531
|
-
morphClass?: string;
|
|
1532
|
-
};
|
|
1533
|
-
};
|
|
1534
|
-
type MorphRelationTypeInput = string | MorphModelTarget | readonly (string | MorphModelTarget)[];
|
|
1535
|
-
type MorphTypeSelector = string | MorphModelTarget | MorphEntityTarget | null;
|
|
1536
|
-
type EagerLoad$1 = {
|
|
1537
|
-
relation: string;
|
|
1538
|
-
constraint?: RelationConstraint$1;
|
|
1539
|
-
};
|
|
1540
|
-
type AggregateLoad$1 = {
|
|
1541
|
-
relation: string;
|
|
1542
|
-
kind: 'count' | 'exists' | 'sum' | 'avg' | 'min' | 'max';
|
|
1543
|
-
constraint?: RelationConstraint$1;
|
|
1544
|
-
column?: string;
|
|
1545
|
-
alias?: string;
|
|
1546
|
-
};
|
|
1547
|
-
declare class ModelQueryBuilder<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap, TLoaded = unknown> {
|
|
1548
|
-
private readonly repository;
|
|
1549
|
-
private readonly tableQuery;
|
|
1550
|
-
private readonly eagerLoads;
|
|
1551
|
-
private readonly relationFilters;
|
|
1552
|
-
private readonly aggregateLoads;
|
|
1553
|
-
private readonly queryCasts;
|
|
1554
|
-
constructor(repository: ModelRepository<TTable>, tableQuery: TableQueryBuilder<TTable, Record<string, unknown>>, eagerLoads?: readonly EagerLoad$1[], relationFilters?: readonly RelationFilter$1[], aggregateLoads?: readonly AggregateLoad$1[], queryCasts?: Readonly<Record<string, ModelCastDefinition>>);
|
|
1555
|
-
getConnection(): DatabaseContext;
|
|
1556
|
-
getConnectionName(): string;
|
|
1557
|
-
getTableQueryBuilder(): TableQueryBuilder<TTable, Record<string, unknown>>;
|
|
1558
|
-
private collectNestedPredicates;
|
|
1559
|
-
private replayNestedPredicates;
|
|
1560
|
-
from(table: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1561
|
-
where(callback: BuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1562
|
-
where(column: ModelColumnName<TTable> | ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1563
|
-
orWhere(callback: BuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1564
|
-
orWhere(column: ModelColumnName<TTable> | ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1565
|
-
whereNot(callback: BuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1566
|
-
orWhereNot(callback: BuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1567
|
-
whereExists<TSubTable extends TableDefinition>(subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1568
|
-
orWhereExists<TSubTable extends TableDefinition>(subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1569
|
-
whereNotExists<TSubTable extends TableDefinition>(subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1570
|
-
orWhereNotExists<TSubTable extends TableDefinition>(subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1571
|
-
whereSub<TSubTable extends TableDefinition>(column: ModelColumnName<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'in' | 'not in' | 'like', subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1572
|
-
orWhereSub<TSubTable extends TableDefinition>(column: ModelColumnName<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'in' | 'not in' | 'like', subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1573
|
-
whereInSub<TSubTable extends TableDefinition>(column: ModelColumnName<TTable>, subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1574
|
-
whereNotInSub<TSubTable extends TableDefinition>(column: ModelColumnName<TTable>, subquery: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1575
|
-
whereNull(column: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1576
|
-
orWhereNull(column: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1577
|
-
whereNotNull(column: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1578
|
-
orWhereNotNull(column: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1579
|
-
when<TValue>(value: TValue, callback: ValueBuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>, TValue>, defaultCallback?: ValueBuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>, TValue>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1580
|
-
unless<TValue>(value: TValue, callback: ValueBuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>, TValue>, defaultCallback?: ValueBuilderCallback$1<ModelQueryBuilder<TTable, TRelations, TLoaded>, TValue>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1581
|
-
orderBy(column: ModelColumnName<TTable>, direction?: 'asc' | 'desc'): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1582
|
-
latest(column?: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1583
|
-
oldest(column?: ModelColumnName<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1584
|
-
inRandomOrder(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1585
|
-
reorder(column?: ModelColumnName<TTable>, direction?: 'asc' | 'desc'): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1586
|
-
lock(mode: 'update' | 'share'): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1587
|
-
lockForUpdate(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1588
|
-
sharedLock(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1589
|
-
withoutGlobalScope(name: string): ModelQueryBuilder<TTable, TRelations>;
|
|
1590
|
-
withoutGlobalScopes(names?: readonly string[]): ModelQueryBuilder<TTable, TRelations>;
|
|
1591
|
-
limit(value?: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1592
|
-
offset(value?: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1593
|
-
skip(value: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1594
|
-
take(value: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1595
|
-
forPage(page: number, perPage?: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1596
|
-
select(...columns: readonly ModelSelectableColumn<TTable>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1597
|
-
addSelect(...columns: readonly ModelSelectableColumn<TTable>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1598
|
-
selectSub<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1599
|
-
addSelectSub<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1600
|
-
distinct(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1601
|
-
withCasts(casts: Record<string, ModelCastDefinition>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1602
|
-
whereColumn(column: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', compareTo: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1603
|
-
whereIn(column: ModelColumnName<TTable>, values: readonly unknown[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1604
|
-
whereNotIn(column: ModelColumnName<TTable>, values: readonly unknown[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1605
|
-
whereBetween(column: ModelColumnName<TTable>, range: readonly [unknown, unknown]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1606
|
-
whereNotBetween(column: ModelColumnName<TTable>, range: readonly [unknown, unknown]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1607
|
-
whereLike(column: ModelColumnName<TTable>, pattern: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1608
|
-
orWhereLike(column: ModelColumnName<TTable>, pattern: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1609
|
-
whereAny(columns: readonly ModelColumnName<TTable>[], operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1610
|
-
whereAll(columns: readonly ModelColumnName<TTable>[], operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1611
|
-
whereNone(columns: readonly ModelColumnName<TTable>[], operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1612
|
-
join(table: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1613
|
-
leftJoin(table: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1614
|
-
rightJoin(table: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1615
|
-
crossJoin(table: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1616
|
-
joinSub<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1617
|
-
leftJoinSub<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1618
|
-
rightJoinSub<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string, leftColumn: ModelColumnReference<TTable>, operator: '!=' | '=' | '>' | '>=' | '<' | '<=' | 'like', rightColumn: ModelColumnReference<TTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1619
|
-
joinLateral<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1620
|
-
leftJoinLateral<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>, alias: string): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1621
|
-
union<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1622
|
-
unionAll<TSubTable extends TableDefinition>(query: SubqueryBuilder<TSubTable>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1623
|
-
groupBy(...columns: readonly ModelColumnName<TTable>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1624
|
-
having(expression: string, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1625
|
-
havingBetween(expression: string, range: readonly [unknown, unknown]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1626
|
-
unsafeWhere(sql: string, bindings: readonly unknown[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1627
|
-
orUnsafeWhere(sql: string, bindings: readonly unknown[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1628
|
-
whereDate(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1629
|
-
whereMonth(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1630
|
-
whereDay(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1631
|
-
whereYear(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1632
|
-
whereTime(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1633
|
-
whereJson(columnPath: ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1634
|
-
orWhereJson(columnPath: ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1635
|
-
whereJsonContains(columnPath: ModelJsonColumnPath<TTable>, value: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1636
|
-
orWhereJsonContains(columnPath: ModelJsonColumnPath<TTable>, value: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1637
|
-
whereJsonLength(columnPath: ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1638
|
-
orWhereJsonLength(columnPath: ModelJsonColumnPath<TTable>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1639
|
-
whereFullText(columns: ModelColumnName<TTable> | readonly ModelColumnName<TTable>[], value: string, options?: {
|
|
1640
|
-
mode?: 'natural' | 'boolean';
|
|
1641
|
-
}): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1642
|
-
orWhereFullText(columns: ModelColumnName<TTable> | readonly ModelColumnName<TTable>[], value: string, options?: {
|
|
1643
|
-
mode?: 'natural' | 'boolean';
|
|
1644
|
-
}): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1645
|
-
whereVectorSimilarTo(column: ModelColumnName<TTable>, vector: readonly number[], minSimilarity?: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1646
|
-
orWhereVectorSimilarTo(column: ModelColumnName<TTable>, vector: readonly number[], minSimilarity?: number): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1647
|
-
unsafeOrderBy(sql: string, bindings: readonly unknown[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1648
|
-
with<TPaths extends readonly ModelRelationPath<TRelations>[]>(...relations: TPaths): ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, TPaths>>;
|
|
1649
|
-
with<TPath extends ModelRelationPath<TRelations>>(relation: TPath, constraint: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, readonly [TPath]>>;
|
|
1650
|
-
with(relations: Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1651
|
-
with<TPaths extends readonly ModelRelationPath<TRelations>[]>(relations: TPaths): ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, TPaths>>;
|
|
1652
|
-
has(relation: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1653
|
-
orHas(relation: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1654
|
-
whereHas(relation: ModelRelationPath<TRelations>, constraint?: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1655
|
-
orWhereHas(relation: ModelRelationPath<TRelations>, constraint?: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1656
|
-
doesntHave(relation: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1657
|
-
orDoesntHave(relation: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1658
|
-
whereDoesntHave(relation: ModelRelationPath<TRelations>, constraint?: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1659
|
-
orWhereDoesntHave(relation: ModelRelationPath<TRelations>, constraint?: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1660
|
-
whereRelation<TRelationPath extends ModelRelationPath<TRelations>>(relation: TRelationPath, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1661
|
-
orWhereRelation<TRelationPath extends ModelRelationPath<TRelations>>(relation: TRelationPath, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1662
|
-
whereMorphRelation<TRelationPath extends ModelRelationPath<TRelations>>(relation: TRelationPath, types: MorphRelationTypeInput, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1663
|
-
orWhereMorphRelation<TRelationPath extends ModelRelationPath<TRelations>>(relation: TRelationPath, types: MorphRelationTypeInput, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, operator: unknown, value?: unknown): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1664
|
-
whereBelongsTo<TRelated extends TableDefinition, TRelatedRelations extends RelationMap = RelationMap>(relatedEntity: Entity<TRelated, TRelatedRelations>, relationName?: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1665
|
-
orWhereBelongsTo<TRelated extends TableDefinition, TRelatedRelations extends RelationMap = RelationMap>(relatedEntity: Entity<TRelated, TRelatedRelations>, relationName?: ModelRelationPath<TRelations>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1666
|
-
whereMorphedTo(relation: ModelRelationPath<TRelations>, target: MorphTypeSelector): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1667
|
-
orWhereMorphedTo(relation: ModelRelationPath<TRelations>, target: MorphTypeSelector): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1668
|
-
whereNotMorphedTo(relation: ModelRelationPath<TRelations>, target: MorphTypeSelector): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1669
|
-
orWhereNotMorphedTo(relation: ModelRelationPath<TRelations>, target: MorphTypeSelector): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1670
|
-
withWhereHas<TPath extends ModelRelationPath<TRelations>>(relation: TPath, constraint?: RelationConstraint$1): ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, readonly [TPath]>>;
|
|
1671
|
-
withCount(...relations: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1672
|
-
withCount(relations: Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1673
|
-
withExists(...relations: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1674
|
-
withExists(relations: Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1675
|
-
withSum<TRelationPath extends ModelRelationPath<TRelations>>(first: TRelationPath | Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, ...rest: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1676
|
-
withAvg<TRelationPath extends ModelRelationPath<TRelations>>(first: TRelationPath | Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, ...rest: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1677
|
-
withMin<TRelationPath extends ModelRelationPath<TRelations>>(first: TRelationPath | Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, ...rest: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1678
|
-
withMax<TRelationPath extends ModelRelationPath<TRelations>>(first: TRelationPath | Readonly<Partial<Record<ModelRelationPath<TRelations>, RelationConstraint$1>>>, column: RelatedColumnNameForRelationPath<TRelations, TRelationPath>, ...rest: readonly ModelRelationPath<TRelations>[]): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1679
|
-
toSQL(): CompiledStatement;
|
|
1680
|
-
debug(): {
|
|
1681
|
-
bindings: unknown[];
|
|
1682
|
-
connectionName: string;
|
|
1683
|
-
scope: TransactionScopeKind;
|
|
1684
|
-
schedulingMode: "concurrent" | "serialized" | "worker";
|
|
1685
|
-
metadata: {
|
|
1686
|
-
debug: {
|
|
1687
|
-
connectionName: string;
|
|
1688
|
-
scope: TransactionScopeKind;
|
|
1689
|
-
schedulingMode: "concurrent" | "serialized" | "worker";
|
|
1690
|
-
tableName: string;
|
|
1691
|
-
hasJoins: boolean;
|
|
1692
|
-
hasUnions: boolean;
|
|
1693
|
-
hasGrouping: boolean;
|
|
1694
|
-
hasHaving: boolean;
|
|
1695
|
-
complexity: number;
|
|
1696
|
-
lockMode?: string;
|
|
1697
|
-
intent: CompiledQueryIntent;
|
|
1698
|
-
transactionAffinity: CompiledQueryTransactionAffinity;
|
|
1699
|
-
streaming: CompiledQueryStreamingMode;
|
|
1700
|
-
};
|
|
1701
|
-
kind: CompiledQueryKind;
|
|
1702
|
-
resultMode: CompiledQueryResultMode;
|
|
1703
|
-
selectedShape: {
|
|
1704
|
-
mode: "all" | "projection" | "write";
|
|
1705
|
-
columns: readonly string[];
|
|
1706
|
-
aggregates: readonly string[];
|
|
1707
|
-
hasRawSelections: boolean;
|
|
1708
|
-
hasSubqueries: boolean;
|
|
1709
|
-
};
|
|
1710
|
-
safety: {
|
|
1711
|
-
unsafe: boolean;
|
|
1712
|
-
containsRawSql: boolean;
|
|
1713
|
-
};
|
|
1714
|
-
} | undefined;
|
|
1715
|
-
unsafe?: true;
|
|
1716
|
-
sql: string;
|
|
1717
|
-
source?: string;
|
|
1718
|
-
};
|
|
1719
|
-
dump(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1720
|
-
cache(config: QueryCacheTtlInput | QueryCacheConfig): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1721
|
-
get(): Promise<ModelCollection<TTable, TRelations, EntityWithLoaded<TTable, TRelations, TLoaded>>>;
|
|
1722
|
-
getJson(): Promise<SerializedEntityWithLoaded<TTable, TLoaded>[]>;
|
|
1723
|
-
first(): Promise<EntityWithLoaded<TTable, TRelations, TLoaded> | undefined>;
|
|
1724
|
-
firstJson(): Promise<SerializedEntityWithLoaded<TTable, TLoaded> | undefined>;
|
|
1725
|
-
sole(): Promise<EntityWithLoaded<TTable, TRelations, TLoaded>>;
|
|
1726
|
-
soleJson(): Promise<SerializedEntityWithLoaded<TTable, TLoaded>>;
|
|
1727
|
-
paginate(perPage?: number, page?: number, options?: PaginationOptions): Promise<PaginatedResult<EntityWithLoaded<TTable, TRelations, TLoaded>>>;
|
|
1728
|
-
paginateJson(perPage?: number, page?: number, options?: PaginationOptions): Promise<{
|
|
1729
|
-
data: readonly SerializedEntityWithLoaded<TTable, TLoaded>[];
|
|
1730
|
-
meta: PaginationMeta;
|
|
1731
|
-
}>;
|
|
1732
|
-
simplePaginate(perPage?: number, page?: number, options?: PaginationOptions): Promise<SimplePaginatedResult<EntityWithLoaded<TTable, TRelations, TLoaded>>>;
|
|
1733
|
-
simplePaginateJson(perPage?: number, page?: number, options?: PaginationOptions): Promise<{
|
|
1734
|
-
data: readonly SerializedEntityWithLoaded<TTable, TLoaded>[];
|
|
1735
|
-
meta: SimplePaginationMeta;
|
|
1736
|
-
}>;
|
|
1737
|
-
cursorPaginate(perPage?: number, cursor?: string | null, options?: CursorPaginationOptions): Promise<CursorPaginatedResult<EntityWithLoaded<TTable, TRelations, TLoaded>>>;
|
|
1738
|
-
cursorPaginateJson(perPage?: number, cursor?: string | null, options?: CursorPaginationOptions): Promise<{
|
|
1739
|
-
data: readonly SerializedEntityWithLoaded<TTable, TLoaded>[];
|
|
1740
|
-
perPage: number;
|
|
1741
|
-
cursorName: string;
|
|
1742
|
-
nextCursor: string | null;
|
|
1743
|
-
prevCursor: string | null;
|
|
1744
|
-
}>;
|
|
1745
|
-
chunk(size: number, callback: (rows: readonly EntityWithLoaded<TTable, TRelations, TLoaded>[], page: number) => unknown | Promise<unknown>): Promise<void>;
|
|
1746
|
-
chunkById(size: number, callback: (rows: readonly EntityWithLoaded<TTable, TRelations, TLoaded>[], page: number) => unknown | Promise<unknown>, column?: ModelAttributeKey<TTable>): Promise<void>;
|
|
1747
|
-
chunkByIdDesc(size: number, callback: (rows: readonly EntityWithLoaded<TTable, TRelations, TLoaded>[], page: number) => unknown | Promise<unknown>, column?: ModelAttributeKey<TTable>): Promise<void>;
|
|
1748
|
-
lazy(size?: number): AsyncGenerator<EntityWithLoaded<TTable, TRelations, TLoaded>, void, unknown>;
|
|
1749
|
-
cursor(): AsyncGenerator<EntityWithLoaded<TTable, TRelations, TLoaded>, void, unknown>;
|
|
1750
|
-
count(): Promise<number>;
|
|
1751
|
-
exists(): Promise<boolean>;
|
|
1752
|
-
doesntExist(): Promise<boolean>;
|
|
1753
|
-
pluck<TColumn extends ModelAttributeKey<TTable>>(column: TColumn): Promise<Array<ModelRecord<TTable>[TColumn]>>;
|
|
1754
|
-
value<TColumn extends ModelAttributeKey<TTable>>(column: TColumn): Promise<ModelRecord<TTable>[TColumn] | undefined>;
|
|
1755
|
-
valueOrFail<TColumn extends ModelAttributeKey<TTable>>(column: TColumn): Promise<ModelRecord<TTable>[TColumn]>;
|
|
1756
|
-
soleValue<TColumn extends ModelAttributeKey<TTable>>(column: TColumn): Promise<ModelRecord<TTable>[TColumn]>;
|
|
1757
|
-
sum(column: ModelColumnName<TTable>): Promise<number>;
|
|
1758
|
-
avg(column: ModelColumnName<TTable>): Promise<number | null>;
|
|
1759
|
-
min(column: ModelColumnName<TTable>): Promise<number | null>;
|
|
1760
|
-
max(column: ModelColumnName<TTable>): Promise<number | null>;
|
|
1761
|
-
firstOrFail(): Promise<EntityWithLoaded<TTable, TRelations, TLoaded>>;
|
|
1762
|
-
find(value: unknown, column?: string): Promise<EntityWithLoaded<TTable, TRelations, TLoaded> | undefined>;
|
|
1763
|
-
findOrFail(value: unknown, column?: string): Promise<EntityWithLoaded<TTable, TRelations, TLoaded>>;
|
|
1764
|
-
findOrFailJson(value: unknown, column?: string): Promise<SerializedEntityWithLoaded<TTable, TLoaded>>;
|
|
1765
|
-
update(values: Partial<ModelRecord<TTable>>): Promise<DriverExecutionResult>;
|
|
1766
|
-
updateJson(columnPath: ModelJsonColumnPath<TTable>, value: unknown): Promise<DriverExecutionResult>;
|
|
1767
|
-
increment(column: ModelColumnName<TTable>, amount?: number, extraValues?: Partial<ModelRecord<TTable>>): Promise<DriverExecutionResult>;
|
|
1768
|
-
decrement(column: ModelColumnName<TTable>, amount?: number, extraValues?: Partial<ModelRecord<TTable>>): Promise<DriverExecutionResult>;
|
|
1769
|
-
upsert(values: Partial<ModelRecord<TTable>> | readonly Partial<ModelRecord<TTable>>[], uniqueBy: readonly ModelColumnName<TTable>[], updateColumns?: readonly ModelColumnName<TTable>[]): Promise<DriverExecutionResult>;
|
|
1770
|
-
delete(): Promise<DriverExecutionResult>;
|
|
1771
|
-
withTrashed(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1772
|
-
onlyTrashed(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1773
|
-
withoutTrashed(): ModelQueryBuilder<TTable, TRelations, TLoaded>;
|
|
1774
|
-
restore(): Promise<number>;
|
|
1775
|
-
forceDelete(): Promise<number>;
|
|
1776
|
-
private clone;
|
|
1777
|
-
private normalizeExistsSubquery;
|
|
1778
|
-
private withRelationFilter;
|
|
1779
|
-
private withAggregateLoads;
|
|
1780
|
-
private normalizeEagerLoads;
|
|
1781
|
-
private mergeEagerLoads;
|
|
1782
|
-
private normalizeAggregateLoads;
|
|
1783
|
-
private normalizeMorphTypes;
|
|
1784
|
-
private applyMorphedToFilter;
|
|
1785
|
-
private applyMorphRelationFilter;
|
|
1786
|
-
private normalizeMorphedToTarget;
|
|
1787
|
-
private isMorphEntityTarget;
|
|
1788
|
-
private getMorphTargetLabels;
|
|
1789
|
-
private assertMorphToRelation;
|
|
1790
|
-
private normalizeColumnAggregateLoads;
|
|
1791
|
-
private parseAggregateRelation;
|
|
1792
|
-
private resolveBelongsToRelation;
|
|
1793
|
-
private applyBelongsToFilter;
|
|
1794
|
-
private resolveBelongsToRelationName;
|
|
1795
|
-
private extractNumericValues;
|
|
1796
|
-
private getUnpaginatedEntities;
|
|
1797
|
-
private prepareCursorPaginationQuery;
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
type CollectionLoadedItem<TItem, TTable extends TableDefinition, TRelations extends RelationMap, TPaths extends readonly ModelRelationPath<TRelations>[]> = Omit<TItem, keyof ResolveEagerLoads<TRelations, TPaths>> & ResolveEagerLoads<TRelations, TPaths> & (TItem extends {
|
|
1801
|
-
toJSON(): infer TSerialized;
|
|
1802
|
-
} ? {
|
|
1803
|
-
toJSON(): TSerialized & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
1804
|
-
} : {
|
|
1805
|
-
toJSON(): ModelRecord<TTable> & SerializeLoaded<ResolveEagerLoads<TRelations, TPaths>>;
|
|
1806
|
-
});
|
|
1807
|
-
type CollectionSerializedItem<TItem, TTable extends TableDefinition> = TItem extends {
|
|
1808
|
-
toJSON(): infer TSerialized;
|
|
1809
|
-
} ? TSerialized : ModelRecord<TTable>;
|
|
1810
|
-
interface ModelCollectionMethods<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap, TItem = Entity<TTable, TRelations>> {
|
|
1811
|
-
modelKeys(): unknown[];
|
|
1812
|
-
toQuery(): ModelQueryBuilder<TTable, TRelations>;
|
|
1813
|
-
toJSON(): Array<CollectionSerializedItem<TItem, TTable>>;
|
|
1814
|
-
load<TPaths extends readonly ModelRelationPath<TRelations>[]>(...relations: TPaths): Promise<ModelCollection<TTable, TRelations, CollectionLoadedItem<TItem, TTable, TRelations, TPaths>>>;
|
|
1815
|
-
loadMissing<TPaths extends readonly ModelRelationPath<TRelations>[]>(...relations: TPaths): Promise<ModelCollection<TTable, TRelations, CollectionLoadedItem<TItem, TTable, TRelations, TPaths>>>;
|
|
1816
|
-
loadMorph(relation: ModelRelationName<TRelations>, mapping: ModelMorphLoadMap): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1817
|
-
loadCount(...relations: readonly ModelRelationName<TRelations>[]): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1818
|
-
loadExists(...relations: readonly ModelRelationName<TRelations>[]): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1819
|
-
loadSum<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1820
|
-
loadAvg<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1821
|
-
loadMin<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1822
|
-
loadMax<TRelationName extends ModelRelationName<TRelations>>(relation: TRelationName, column: RelatedColumnNameOfRelation<TRelations[TRelationName]>): Promise<ModelCollection<TTable, TRelations, TItem>>;
|
|
1823
|
-
fresh(): Promise<ModelCollection<TTable, TRelations>>;
|
|
1824
|
-
append(...keys: readonly string[]): ModelCollection<TTable, TRelations, TItem>;
|
|
1825
|
-
withoutAppends(): ModelCollection<TTable, TRelations, TItem>;
|
|
1826
|
-
makeVisible(...keys: readonly string[]): ModelCollection<TTable, TRelations, TItem>;
|
|
1827
|
-
makeHidden(...keys: readonly string[]): ModelCollection<TTable, TRelations, TItem>;
|
|
1828
|
-
setVisible(keys: readonly string[]): ModelCollection<TTable, TRelations, TItem>;
|
|
1829
|
-
setHidden(keys: readonly string[]): ModelCollection<TTable, TRelations, TItem>;
|
|
1830
|
-
}
|
|
1831
|
-
type ModelCollection<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap, TItem = Entity<TTable, TRelations>> = Array<TItem> & ModelCollectionMethods<TTable, TRelations, TItem>;
|
|
1832
|
-
|
|
1833
|
-
type SelectRow<TTableOrName extends string | TableDefinition> = TTableOrName extends TableDefinition ? InferSelect<TTableOrName> : Record<string, unknown>;
|
|
1834
|
-
type TableReference = string | TableDefinition;
|
|
1835
|
-
type BuilderCallback<TBuilder> = (query: TBuilder) => unknown;
|
|
1836
|
-
type ValueBuilderCallback<TBuilder, TValue> = (query: TBuilder, value: TValue) => unknown;
|
|
1837
|
-
type SelectedColumnNames<TRow extends Record<string, unknown>> = Extract<keyof TRow, string>;
|
|
1838
|
-
type ExactDeclaredColumnName<TTableOrName extends TableReference> = TTableOrName extends TableDefinition ? Extract<keyof SelectRow<TTableOrName>, string> : string;
|
|
1839
|
-
type DeclaredColumnName<TTableOrName extends TableReference> = TTableOrName extends TableDefinition ? ExactDeclaredColumnName<TTableOrName> | `${string}.${ExactDeclaredColumnName<TTableOrName>}` : string;
|
|
1840
|
-
type AliasedColumnSelection<TTableOrName extends TableReference> = TTableOrName extends TableDefinition ? `${DeclaredColumnName<TTableOrName>} as ${string}` : string;
|
|
1841
|
-
type ColumnReference<TTableOrName extends TableReference> = TTableOrName extends TableDefinition ? DeclaredColumnName<TTableOrName> | `${string}.${string}` : string;
|
|
1842
|
-
type JsonColumnPath<TTableOrName extends TableReference> = TTableOrName extends TableDefinition ? DeclaredColumnName<TTableOrName> | `${DeclaredColumnName<TTableOrName>}->${string}` : string;
|
|
1843
|
-
type SelectionResult<TTableOrName extends TableReference, TCurrentRow extends Record<string, unknown>, TColumns extends readonly SelectedColumnNames<SelectRow<TTableOrName>>[]> = TColumns extends readonly [] ? TCurrentRow : Pick<SelectRow<TTableOrName>, TColumns[number]>;
|
|
1844
|
-
type MergeSelections<TTableOrName extends TableReference, TCurrentRow extends Record<string, unknown>, TColumns extends readonly SelectedColumnNames<SelectRow<TTableOrName>>[]> = TCurrentRow & Pick<SelectRow<TTableOrName>, TColumns[number]>;
|
|
1845
|
-
type AggregateSelectionResult<TAlias extends string, TValue> = Record<TAlias, TValue>;
|
|
1846
|
-
declare class TableQueryBuilder<TTableOrName extends TableReference = string, TSelectedRow extends Record<string, unknown> = SelectRow<TTableOrName>> {
|
|
1847
|
-
private readonly connection;
|
|
1848
|
-
private readonly queryCacheConfig?;
|
|
1849
|
-
private readonly source;
|
|
1850
|
-
private readonly plan;
|
|
1851
|
-
constructor(table: TTableOrName, connection: DatabaseContext, plan?: SelectQueryPlan, queryCacheConfig?: NormalizedQueryCacheConfig | undefined);
|
|
1852
|
-
getTableName(): string;
|
|
1853
|
-
getConnectionName(): string;
|
|
1854
|
-
getConnection(): DatabaseContext;
|
|
1855
|
-
getPlan(): SelectQueryPlan;
|
|
1856
|
-
from(table: string): TableQueryBuilder<string, TSelectedRow>;
|
|
1857
|
-
select<const TColumns extends readonly SelectedColumnNames<SelectRow<TTableOrName>>[]>(...columns: TColumns): TableQueryBuilder<TTableOrName, SelectionResult<TTableOrName, TSelectedRow, TColumns>>;
|
|
1858
|
-
select(...columns: readonly (DeclaredColumnName<TTableOrName> | AliasedColumnSelection<TTableOrName>)[]): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1859
|
-
addSelect<const TColumns extends readonly SelectedColumnNames<SelectRow<TTableOrName>>[]>(...columns: TColumns): TableQueryBuilder<TTableOrName, MergeSelections<TTableOrName, TSelectedRow, TColumns>>;
|
|
1860
|
-
addSelect(...columns: readonly (DeclaredColumnName<TTableOrName> | AliasedColumnSelection<TTableOrName>)[]): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1861
|
-
selectCount<TAlias extends string = 'count'>(alias?: TAlias, column?: DeclaredColumnName<TTableOrName> | '*'): TableQueryBuilder<TTableOrName, AggregateSelectionResult<TAlias, number>>;
|
|
1862
|
-
addSelectCount<TAlias extends string = 'count'>(alias?: TAlias, column?: DeclaredColumnName<TTableOrName> | '*'): TableQueryBuilder<TTableOrName, TSelectedRow & AggregateSelectionResult<TAlias, number>>;
|
|
1863
|
-
selectSum<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, AggregateSelectionResult<TAlias, number | null>>;
|
|
1864
|
-
addSelectSum<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow & AggregateSelectionResult<TAlias, number | null>>;
|
|
1865
|
-
selectAvg<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, AggregateSelectionResult<TAlias, number | null>>;
|
|
1866
|
-
addSelectAvg<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow & AggregateSelectionResult<TAlias, number | null>>;
|
|
1867
|
-
selectMin<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, AggregateSelectionResult<TAlias, number | null>>;
|
|
1868
|
-
addSelectMin<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow & AggregateSelectionResult<TAlias, number | null>>;
|
|
1869
|
-
selectMax<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, AggregateSelectionResult<TAlias, number | null>>;
|
|
1870
|
-
addSelectMax<TAlias extends string>(alias: TAlias, column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow & AggregateSelectionResult<TAlias, number | null>>;
|
|
1871
|
-
unsafeSelect(sql: string, bindings: readonly unknown[]): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1872
|
-
addUnsafeSelect(sql: string, bindings: readonly unknown[]): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1873
|
-
selectSub(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1874
|
-
addSelectSub(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string): TableQueryBuilder<TTableOrName, Record<string, unknown>>;
|
|
1875
|
-
distinct(): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1876
|
-
where(callback: BuilderCallback<TableQueryBuilder<TTableOrName, SelectRow<TTableOrName>>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1877
|
-
where(column: JsonColumnPath<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1878
|
-
orWhere(callback: BuilderCallback<TableQueryBuilder<TTableOrName, SelectRow<TTableOrName>>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1879
|
-
orWhere(column: JsonColumnPath<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1880
|
-
private whereGroupWithBoolean;
|
|
1881
|
-
whereNot(callback: BuilderCallback<TableQueryBuilder<TTableOrName, SelectRow<TTableOrName>>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1882
|
-
orWhereNot(callback: BuilderCallback<TableQueryBuilder<TTableOrName, SelectRow<TTableOrName>>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1883
|
-
whereExists(subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1884
|
-
orWhereExists(subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1885
|
-
whereNotExists(subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1886
|
-
orWhereNotExists(subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1887
|
-
whereSub(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator, subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1888
|
-
orWhereSub(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator, subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1889
|
-
whereInSub(column: DeclaredColumnName<TTableOrName>, subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1890
|
-
whereNotInSub(column: DeclaredColumnName<TTableOrName>, subquery: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1891
|
-
private whereWithBoolean;
|
|
1892
|
-
private whereExistsWithBoolean;
|
|
1893
|
-
private whereSubWithBoolean;
|
|
1894
|
-
private whereDatePart;
|
|
1895
|
-
private isScalarJsonValue;
|
|
1896
|
-
private createAggregateSelection;
|
|
1897
|
-
private getColumnDefinition;
|
|
1898
|
-
private assertJsonRootColumn;
|
|
1899
|
-
private parseJsonPath;
|
|
1900
|
-
private whereJsonValueWithBoolean;
|
|
1901
|
-
private whereJsonContainsWithBoolean;
|
|
1902
|
-
private whereJsonLengthWithBoolean;
|
|
1903
|
-
whereNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1904
|
-
orWhereNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1905
|
-
private whereNullWithBoolean;
|
|
1906
|
-
whereNotNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1907
|
-
orWhereNotNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1908
|
-
private whereNotNullWithBoolean;
|
|
1909
|
-
whereColumn(column: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, compareTo: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1910
|
-
whereIn(column: DeclaredColumnName<TTableOrName>, values: readonly unknown[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1911
|
-
whereNotIn(column: DeclaredColumnName<TTableOrName>, values: readonly unknown[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1912
|
-
whereBetween(column: DeclaredColumnName<TTableOrName>, range: readonly [unknown, unknown]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1913
|
-
whereNotBetween(column: DeclaredColumnName<TTableOrName>, range: readonly [unknown, unknown]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1914
|
-
whereLike(column: DeclaredColumnName<TTableOrName>, pattern: string): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1915
|
-
orWhereLike(column: DeclaredColumnName<TTableOrName>, pattern: string): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1916
|
-
whereAny(columns: readonly DeclaredColumnName<TTableOrName>[], operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1917
|
-
whereAll(columns: readonly DeclaredColumnName<TTableOrName>[], operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1918
|
-
whereNone(columns: readonly DeclaredColumnName<TTableOrName>[], operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1919
|
-
whereDate(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1920
|
-
whereMonth(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1921
|
-
whereDay(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1922
|
-
whereYear(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1923
|
-
whereTime(column: DeclaredColumnName<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1924
|
-
whereJson(columnPath: JsonColumnPath<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1925
|
-
orWhereJson(columnPath: JsonColumnPath<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1926
|
-
whereJsonContains(columnPath: JsonColumnPath<TTableOrName>, value: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1927
|
-
orWhereJsonContains(columnPath: JsonColumnPath<TTableOrName>, value: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1928
|
-
whereJsonLength(columnPath: JsonColumnPath<TTableOrName>, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1929
|
-
groupBy(...columns: readonly DeclaredColumnName<TTableOrName>[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1930
|
-
join(table: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1931
|
-
leftJoin(table: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1932
|
-
rightJoin(table: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1933
|
-
joinSub(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1934
|
-
leftJoinSub(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1935
|
-
rightJoinSub(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string, leftColumn: ColumnReference<TTableOrName>, operator: Exclude<QueryOperator, 'in' | 'not in' | 'between' | 'not between'>, rightColumn: ColumnReference<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1936
|
-
joinLateral(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1937
|
-
leftJoinLateral(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>, alias: string): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1938
|
-
crossJoin(table: string): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1939
|
-
union(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1940
|
-
unionAll(query: TableQueryBuilder<TableDefinition, Record<string, unknown>>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1941
|
-
having(expression: string, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1942
|
-
havingBetween(expression: string, range: readonly [unknown, unknown]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1943
|
-
orWhereJsonLength(columnPath: string, operator: QueryOperator | unknown, value?: unknown): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1944
|
-
unsafeWhere(sql: string, bindings: readonly unknown[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1945
|
-
orUnsafeWhere(sql: string, bindings: readonly unknown[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1946
|
-
whereFullText(columns: DeclaredColumnName<TTableOrName> | readonly DeclaredColumnName<TTableOrName>[], value: string, options?: {
|
|
1947
|
-
mode?: 'natural' | 'boolean';
|
|
1948
|
-
}): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1949
|
-
orWhereFullText(columns: DeclaredColumnName<TTableOrName> | readonly DeclaredColumnName<TTableOrName>[], value: string, options?: {
|
|
1950
|
-
mode?: 'natural' | 'boolean';
|
|
1951
|
-
}): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1952
|
-
whereVectorSimilarTo(column: DeclaredColumnName<TTableOrName>, vector: readonly number[], minSimilarity?: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1953
|
-
orWhereVectorSimilarTo(column: DeclaredColumnName<TTableOrName>, vector: readonly number[], minSimilarity?: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1954
|
-
when<TValue>(value: TValue, callback: ValueBuilderCallback<TableQueryBuilder<TTableOrName, TSelectedRow>, TValue>, defaultCallback?: ValueBuilderCallback<TableQueryBuilder<TTableOrName, TSelectedRow>, TValue>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1955
|
-
unless<TValue>(value: TValue, callback: ValueBuilderCallback<TableQueryBuilder<TTableOrName, TSelectedRow>, TValue>, defaultCallback?: ValueBuilderCallback<TableQueryBuilder<TTableOrName, TSelectedRow>, TValue>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1956
|
-
withoutWhereNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1957
|
-
withoutWhereNotNull(column: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1958
|
-
orderBy(column: DeclaredColumnName<TTableOrName>, direction?: QueryDirection): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1959
|
-
unsafeOrderBy(sql: string, bindings: readonly unknown[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1960
|
-
inRandomOrder(): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1961
|
-
latest(column?: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1962
|
-
oldest(column?: DeclaredColumnName<TTableOrName>): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1963
|
-
reorder(column?: DeclaredColumnName<TTableOrName>, direction?: QueryDirection): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1964
|
-
orderByVectorSimilarity(column: DeclaredColumnName<TTableOrName>, vector: readonly number[]): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1965
|
-
lock(mode: 'update' | 'share'): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1966
|
-
lockForUpdate(): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1967
|
-
sharedLock(): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1968
|
-
limit(value?: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1969
|
-
offset(value?: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1970
|
-
skip(value: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1971
|
-
take(value: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1972
|
-
forPage(page: number, perPage?: number): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
1973
|
-
toSQL(): CompiledStatement;
|
|
1974
|
-
debug(): {
|
|
1975
|
-
bindings: unknown[];
|
|
1976
|
-
connectionName: string;
|
|
1977
|
-
scope: TransactionScopeKind;
|
|
1978
|
-
schedulingMode: "concurrent" | "serialized" | "worker";
|
|
1979
|
-
metadata: {
|
|
1980
|
-
debug: {
|
|
1981
|
-
connectionName: string;
|
|
1982
|
-
scope: TransactionScopeKind;
|
|
1983
|
-
schedulingMode: "concurrent" | "serialized" | "worker";
|
|
1984
|
-
tableName: string;
|
|
1985
|
-
hasJoins: boolean;
|
|
1986
|
-
hasUnions: boolean;
|
|
1987
|
-
hasGrouping: boolean;
|
|
1988
|
-
hasHaving: boolean;
|
|
1989
|
-
complexity: number;
|
|
1990
|
-
lockMode?: string;
|
|
1991
|
-
intent: CompiledQueryIntent;
|
|
1992
|
-
transactionAffinity: CompiledQueryTransactionAffinity;
|
|
1993
|
-
streaming: CompiledQueryStreamingMode;
|
|
1994
|
-
};
|
|
1995
|
-
kind: CompiledQueryKind;
|
|
1996
|
-
resultMode: CompiledQueryResultMode;
|
|
1997
|
-
selectedShape: {
|
|
1998
|
-
mode: "all" | "projection" | "write";
|
|
1999
|
-
columns: readonly string[];
|
|
2000
|
-
aggregates: readonly string[];
|
|
2001
|
-
hasRawSelections: boolean;
|
|
2002
|
-
hasSubqueries: boolean;
|
|
2003
|
-
};
|
|
2004
|
-
safety: {
|
|
2005
|
-
unsafe: boolean;
|
|
2006
|
-
containsRawSql: boolean;
|
|
2007
|
-
};
|
|
2008
|
-
} | undefined;
|
|
2009
|
-
unsafe?: true;
|
|
2010
|
-
sql: string;
|
|
2011
|
-
source?: string;
|
|
2012
|
-
};
|
|
2013
|
-
dump(): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
2014
|
-
cache(config: QueryCacheTtlInput | QueryCacheConfig): TableQueryBuilder<TTableOrName, TSelectedRow>;
|
|
2015
|
-
get<TRow extends Record<string, unknown> = TSelectedRow>(): Promise<TRow[]>;
|
|
2016
|
-
first<TRow extends Record<string, unknown> = TSelectedRow>(): Promise<TRow | undefined>;
|
|
2017
|
-
sole<TRow extends Record<string, unknown> = TSelectedRow>(): Promise<TRow>;
|
|
2018
|
-
paginate<TRow extends Record<string, unknown> = TSelectedRow>(perPage?: number, page?: number, options?: PaginationOptions): Promise<PaginatedResult<TRow>>;
|
|
2019
|
-
simplePaginate<TRow extends Record<string, unknown> = TSelectedRow>(perPage?: number, page?: number, options?: PaginationOptions): Promise<SimplePaginatedResult<TRow>>;
|
|
2020
|
-
cursorPaginate<TRow extends Record<string, unknown> = TSelectedRow>(perPage?: number, cursor?: string | null, options?: CursorPaginationOptions): Promise<CursorPaginatedResult<TRow>>;
|
|
2021
|
-
chunk<TRow extends Record<string, unknown> = TSelectedRow>(size: number, callback: (rows: readonly TRow[], page: number) => unknown | Promise<unknown>): Promise<void>;
|
|
2022
|
-
chunkById<TRow extends Record<string, unknown> = TSelectedRow>(size: number, callback: (rows: readonly TRow[], page: number) => unknown | Promise<unknown>, column?: string): Promise<void>;
|
|
2023
|
-
chunkByIdDesc<TRow extends Record<string, unknown> = TSelectedRow>(size: number, callback: (rows: readonly TRow[], page: number) => unknown | Promise<unknown>, column?: string): Promise<void>;
|
|
2024
|
-
lazy<TRow extends Record<string, unknown> = TSelectedRow>(size?: number): AsyncGenerator<TRow, void, unknown>;
|
|
2025
|
-
cursor<TRow extends Record<string, unknown> = TSelectedRow>(): AsyncGenerator<TRow, void, unknown>;
|
|
2026
|
-
count(): Promise<number>;
|
|
2027
|
-
exists(): Promise<boolean>;
|
|
2028
|
-
doesntExist(): Promise<boolean>;
|
|
2029
|
-
pluck<TKey extends SelectedColumnNames<TSelectedRow>>(column: TKey): Promise<Array<TSelectedRow[TKey]>>;
|
|
2030
|
-
value<TKey extends SelectedColumnNames<TSelectedRow>>(column: TKey): Promise<TSelectedRow[TKey] | undefined>;
|
|
2031
|
-
valueOrFail<TKey extends SelectedColumnNames<TSelectedRow>>(column: TKey): Promise<TSelectedRow[TKey]>;
|
|
2032
|
-
soleValue<TKey extends SelectedColumnNames<TSelectedRow>>(column: TKey): Promise<TSelectedRow[TKey]>;
|
|
2033
|
-
sum(column: string): Promise<number>;
|
|
2034
|
-
avg(column: string): Promise<number | null>;
|
|
2035
|
-
min(column: string): Promise<number | null>;
|
|
2036
|
-
max(column: string): Promise<number | null>;
|
|
2037
|
-
find<TRow extends Record<string, unknown> = TSelectedRow>(value: unknown, column?: string): Promise<TRow | undefined>;
|
|
2038
|
-
insert(values: Readonly<Record<string, unknown>> | readonly Readonly<Record<string, unknown>>[]): Promise<DriverExecutionResult>;
|
|
2039
|
-
insertOrIgnore(values: Readonly<Record<string, unknown>> | readonly Readonly<Record<string, unknown>>[]): Promise<DriverExecutionResult>;
|
|
2040
|
-
insertGetId(values: Readonly<Record<string, unknown>>): Promise<number | string | undefined>;
|
|
2041
|
-
upsert(values: Readonly<Record<string, unknown>> | readonly Readonly<Record<string, unknown>>[], uniqueBy: readonly string[], updateColumns?: readonly string[]): Promise<DriverExecutionResult>;
|
|
2042
|
-
increment(column: string, amount?: number, extraValues?: Readonly<Record<string, unknown>>): Promise<DriverExecutionResult>;
|
|
2043
|
-
decrement(column: string, amount?: number, extraValues?: Readonly<Record<string, unknown>>): Promise<DriverExecutionResult>;
|
|
2044
|
-
update(values: Readonly<Record<string, unknown>>): Promise<DriverExecutionResult>;
|
|
2045
|
-
updateJson(columnPath: string, value: unknown): Promise<DriverExecutionResult>;
|
|
2046
|
-
delete(): Promise<DriverExecutionResult>;
|
|
2047
|
-
unsafeQuery<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: Omit<UnsafeStatement, 'source'>): Promise<DriverQueryResult<TRow>>;
|
|
2048
|
-
unsafeExecute(statement: Omit<UnsafeStatement, 'source'>): Promise<DriverExecutionResult>;
|
|
2049
|
-
private clone;
|
|
2050
|
-
private invalidateSourceTableQueries;
|
|
2051
|
-
private getCompiler;
|
|
2052
|
-
private getUnpaginatedRows;
|
|
2053
|
-
private resolvePrimaryKeyColumn;
|
|
2054
|
-
private normalizeOperatorValue;
|
|
2055
|
-
private adjustNumericColumn;
|
|
2056
|
-
private whereMultiColumns;
|
|
2057
|
-
private whereFullTextWithBoolean;
|
|
2058
|
-
private whereVectorSimilarToWithBoolean;
|
|
2059
|
-
private prepareCursorPaginationQuery;
|
|
2060
|
-
private aggregateNumeric;
|
|
2061
|
-
private extractNumericValues;
|
|
2062
|
-
private normalizeUpdateValues;
|
|
2063
|
-
private normalizeWriteRecord;
|
|
2064
|
-
private normalizeWriteValueForColumn;
|
|
2065
|
-
private normalizePredicateValueForColumn;
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
type WriteMode = 'create' | 'update';
|
|
2069
|
-
type PivotAttributes = Record<string, unknown>;
|
|
2070
|
-
type PivotSyncResult = {
|
|
2071
|
-
attached: unknown[];
|
|
2072
|
-
detached: unknown[];
|
|
2073
|
-
updated: unknown[];
|
|
2074
|
-
};
|
|
2075
|
-
type PivotToggleResult = {
|
|
2076
|
-
attached: unknown[];
|
|
2077
|
-
detached: unknown[];
|
|
2078
|
-
};
|
|
2079
|
-
type RelationConstraint = (query: ModelQueryBuilder<TableDefinition>) => unknown;
|
|
2080
|
-
type RelationFilter = {
|
|
2081
|
-
relation: string;
|
|
2082
|
-
negate: boolean;
|
|
2083
|
-
constraint?: RelationConstraint;
|
|
2084
|
-
boolean?: 'and' | 'or';
|
|
2085
|
-
morphTypes?: readonly string[];
|
|
2086
|
-
};
|
|
2087
|
-
type EagerLoad = {
|
|
2088
|
-
relation: string;
|
|
2089
|
-
constraint?: RelationConstraint;
|
|
2090
|
-
};
|
|
2091
|
-
type AggregateLoad = {
|
|
2092
|
-
relation: string;
|
|
2093
|
-
kind: RelationAggregateKind;
|
|
2094
|
-
constraint?: RelationConstraint;
|
|
2095
|
-
column?: string;
|
|
2096
|
-
alias?: string;
|
|
2097
|
-
};
|
|
2098
|
-
declare class ModelRepository<TTable extends TableDefinition = TableDefinition> {
|
|
2099
|
-
private readonly connection;
|
|
2100
|
-
readonly definition: ModelDefinition<TTable>;
|
|
2101
|
-
constructor(definition: ModelDefinition<TTable>, connection: DatabaseContext);
|
|
2102
|
-
static from<TTable extends TableDefinition>(reference: ModelDefinitionLike | ModelDefinition<TTable> | ModelReference<TTable>, connection?: DatabaseContext): ModelRepository<TTable>;
|
|
2103
|
-
getConnection(): DatabaseContext;
|
|
2104
|
-
getConnectionName(): string;
|
|
2105
|
-
getDeletedAtColumn(): string | undefined;
|
|
2106
|
-
getRelationNames(): readonly string[];
|
|
2107
|
-
getRelationDefinition(name: string): RelationDefinition;
|
|
2108
|
-
createCollection<TItem extends Entity<TTable>>(items: readonly TItem[]): ModelCollection<TTable, RelationMap, TItem>;
|
|
2109
|
-
query(): ModelQueryBuilder<TTable>;
|
|
2110
|
-
newQuery(): ModelQueryBuilder<TTable>;
|
|
2111
|
-
newModelQuery(): ModelQueryBuilder<TTable>;
|
|
2112
|
-
newQueryWithoutScopes(): ModelQueryBuilder<TTable>;
|
|
2113
|
-
queryWithoutGlobalScope(name: string): ModelQueryBuilder<TTable>;
|
|
2114
|
-
queryWithoutGlobalScopes(names?: readonly string[]): ModelQueryBuilder<TTable>;
|
|
2115
|
-
newQueryWithoutRelationships(): ModelQueryBuilder<TTable>;
|
|
2116
|
-
find(value: unknown): Promise<Entity<TTable> | undefined>;
|
|
2117
|
-
findOrFail(value: unknown): Promise<Entity<TTable>>;
|
|
2118
|
-
first(): Promise<Entity<TTable> | undefined>;
|
|
2119
|
-
firstOrFail(): Promise<Entity<TTable>>;
|
|
2120
|
-
get(): Promise<ModelCollection<TTable>>;
|
|
2121
|
-
sole(): Promise<Entity<TTable>>;
|
|
2122
|
-
all(): Promise<ModelCollection<TTable>>;
|
|
2123
|
-
findMany(values: readonly unknown[]): Promise<ModelCollection<TTable>>;
|
|
2124
|
-
firstWhere(column: ModelColumnName<TTable>, operator: unknown, value?: unknown): Promise<Entity<TTable> | undefined>;
|
|
2125
|
-
firstOrNew(match: Partial<ModelRecord<TTable>>, values?: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2126
|
-
firstOrCreate(match: Partial<ModelRecord<TTable>>, values?: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2127
|
-
make(values?: Partial<ModelRecord<TTable>>): Entity<TTable>;
|
|
2128
|
-
hydrate(values: Partial<ModelRecord<TTable>>): Entity<TTable>;
|
|
2129
|
-
retrieve(values: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2130
|
-
retrieveWithCasts(values: Partial<ModelRecord<TTable>>, casts: Record<string, ModelCastDefinition>): Promise<Entity<TTable>>;
|
|
2131
|
-
freshEntity(entity: Entity<TTable>): Promise<Entity<TTable> | undefined>;
|
|
2132
|
-
refreshEntity(entity: Entity<TTable>): Promise<Entity<TTable>>;
|
|
2133
|
-
loadRelations(entities: readonly Entity<TTable>[], relations: readonly (string | EagerLoad)[], missingOnly?: boolean): Promise<void>;
|
|
2134
|
-
filterByRelations(entities: readonly Entity<TTable>[], filters: readonly RelationFilter[]): Promise<Array<Entity<TTable>>>;
|
|
2135
|
-
applyRelationExistenceFilter(query: TableQueryBuilder<TTable, Record<string, unknown>>, filter: RelationFilter): TableQueryBuilder<TTable, Record<string, unknown>>;
|
|
2136
|
-
loadMorphRelations(entities: readonly Entity<TTable>[], relationName: string, mapping: Readonly<Record<string, string | readonly string[] | Readonly<Record<string, RelationConstraint>>>>): Promise<void>;
|
|
2137
|
-
loadRelationAggregates(entities: readonly Entity<TTable>[], aggregates: readonly AggregateLoad[]): Promise<void>;
|
|
2138
|
-
create(values: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2139
|
-
createQuietly(values: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2140
|
-
createMany(values: readonly Partial<ModelRecord<TTable>>[]): Promise<ModelCollection<TTable>>;
|
|
2141
|
-
createManyQuietly(values: readonly Partial<ModelRecord<TTable>>[]): Promise<ModelCollection<TTable>>;
|
|
2142
|
-
saveMany(entities: readonly Entity<TTable>[]): Promise<ModelCollection<TTable>>;
|
|
2143
|
-
saveManyQuietly(entities: readonly Entity<TTable>[]): Promise<ModelCollection<TTable>>;
|
|
2144
|
-
update(id: unknown, values: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2145
|
-
delete(id: unknown): Promise<void>;
|
|
2146
|
-
destroy(ids: readonly unknown[]): Promise<number>;
|
|
2147
|
-
prune(): Promise<number>;
|
|
2148
|
-
associateRelation(entity: Entity<TTable>, relationName: string, relatedEntity: Entity | null): Entity<TTable>;
|
|
2149
|
-
dissociateRelation(entity: Entity<TTable>, relationName: string): Entity<TTable>;
|
|
2150
|
-
saveRelatedEntity(entity: Entity<TTable>, relationName: string, relatedEntity: Entity): Promise<Entity>;
|
|
2151
|
-
saveRelatedEntityQuietly(entity: Entity<TTable>, relationName: string, relatedEntity: Entity): Promise<Entity>;
|
|
2152
|
-
saveManyRelatedEntities(entity: Entity<TTable>, relationName: string, relatedEntities: readonly Entity[]): Promise<Entity[]>;
|
|
2153
|
-
saveManyRelatedEntitiesQuietly(entity: Entity<TTable>, relationName: string, relatedEntities: readonly Entity[]): Promise<Entity[]>;
|
|
2154
|
-
createRelatedEntity(entity: Entity<TTable>, relationName: string, values: Record<string, unknown>): Promise<Entity>;
|
|
2155
|
-
createRelatedEntityQuietly(entity: Entity<TTable>, relationName: string, values: Record<string, unknown>): Promise<Entity>;
|
|
2156
|
-
createManyRelatedEntities(entity: Entity<TTable>, relationName: string, values: readonly Record<string, unknown>[]): Promise<ModelCollection>;
|
|
2157
|
-
createManyRelatedEntitiesQuietly(entity: Entity<TTable>, relationName: string, values: readonly Record<string, unknown>[]): Promise<ModelCollection>;
|
|
2158
|
-
private createRecord;
|
|
2159
|
-
restore(id: unknown): Promise<Entity<TTable>>;
|
|
2160
|
-
forceDelete(id: unknown): Promise<void>;
|
|
2161
|
-
upsert(match: Partial<ModelRecord<TTable>>, values?: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2162
|
-
updateOrCreate(match: Partial<ModelRecord<TTable>>, values?: Partial<ModelRecord<TTable>>): Promise<Entity<TTable>>;
|
|
2163
|
-
sanitizeWritePayload(values: Partial<ModelRecord<TTable>> | Record<string, unknown>, mode: WriteMode, internalColumns?: ReadonlySet<string>): Partial<ModelUpdatePayload<TTable>>;
|
|
2164
|
-
saveEntity(entity: Entity<TTable>, internalColumns?: ReadonlySet<string>): Promise<Entity<TTable>>;
|
|
2165
|
-
saveEntityQuietly(entity: Entity<TTable>, internalColumns?: ReadonlySet<string>): Promise<Entity<TTable>>;
|
|
2166
|
-
deleteEntity(entity: Entity<TTable>): Promise<void>;
|
|
2167
|
-
deleteEntityQuietly(entity: Entity<TTable>): Promise<void>;
|
|
2168
|
-
shouldKeepEntityPersistedOnDelete(): boolean;
|
|
2169
|
-
restoreEntity(entity: Entity<TTable>): Promise<Entity<TTable>>;
|
|
2170
|
-
restoreEntityQuietly(entity: Entity<TTable>): Promise<Entity<TTable>>;
|
|
2171
|
-
forceDeleteEntity(entity: Entity<TTable>): Promise<void>;
|
|
2172
|
-
private runWriteUnit;
|
|
2173
|
-
forceDeleteEntityQuietly(entity: Entity<TTable>): Promise<void>;
|
|
2174
|
-
replicateEntity(entity: Entity<TTable>, except?: readonly string[]): Entity<TTable>;
|
|
2175
|
-
attachRelation(entity: Entity<TTable>, relationName: string, ids: unknown, attributes?: PivotAttributes): Promise<void>;
|
|
2176
|
-
detachRelation(entity: Entity<TTable>, relationName: string, ids?: unknown): Promise<number>;
|
|
2177
|
-
syncRelation(entity: Entity<TTable>, relationName: string, ids: unknown, detachMissing: boolean): Promise<PivotSyncResult>;
|
|
2178
|
-
updateExistingPivot(entity: Entity<TTable>, relationName: string, id: unknown, attributes: PivotAttributes): Promise<number>;
|
|
2179
|
-
toggleRelation(entity: Entity<TTable>, relationName: string, ids: unknown): Promise<PivotToggleResult>;
|
|
2180
|
-
private loadRelation;
|
|
2181
|
-
private createQuery;
|
|
2182
|
-
private collectLoadedRelationEntities;
|
|
2183
|
-
private loadBelongsToRelation;
|
|
2184
|
-
private loadHasManyRelation;
|
|
2185
|
-
private loadHasOneRelation;
|
|
2186
|
-
private loadHasOneOfManyRelation;
|
|
2187
|
-
private loadMorphManyRelation;
|
|
2188
|
-
private loadMorphOneRelation;
|
|
2189
|
-
private loadMorphOneOfManyRelation;
|
|
2190
|
-
private loadMorphToRelation;
|
|
2191
|
-
private loadHasManyThroughRelation;
|
|
2192
|
-
private loadHasOneThroughRelation;
|
|
2193
|
-
private loadBelongsToManyRelation;
|
|
2194
|
-
private loadMorphToManyRelation;
|
|
2195
|
-
private loadMorphedByManyRelation;
|
|
2196
|
-
private resolveRelatedRepository;
|
|
2197
|
-
private resolveThroughRepository;
|
|
2198
|
-
private getMorphTypeValue;
|
|
2199
|
-
private resolveMorphRepository;
|
|
2200
|
-
private normalizeEagerLoads;
|
|
2201
|
-
private getMatchingParentKeys;
|
|
2202
|
-
private getRelationMatchCounts;
|
|
2203
|
-
private applyRelationConstraint;
|
|
2204
|
-
private buildRelationExistenceSubqueries;
|
|
2205
|
-
private resolveMorphExistenceReferences;
|
|
2206
|
-
private assertRelationExistenceSupported;
|
|
2207
|
-
private applyExistsBoolean;
|
|
2208
|
-
private applyExistsBooleanGroup;
|
|
2209
|
-
private qualifyParentColumn;
|
|
2210
|
-
private getRelationParentValue;
|
|
2211
|
-
private getAggregateAttributeKey;
|
|
2212
|
-
private getRelationAggregateValues;
|
|
2213
|
-
private computeAggregateValue;
|
|
2214
|
-
private assertNumericAggregateValue;
|
|
2215
|
-
private getRelatedEntitiesByParentKey;
|
|
2216
|
-
attachCollection(entities: readonly Entity<TTable>[]): readonly Entity<TTable>[];
|
|
2217
|
-
resolveRelationProperty(entity: Entity<TTable>, relationName: string): unknown;
|
|
2218
|
-
private getMatchingBelongsToParentKeys;
|
|
2219
|
-
private getBelongsToMatchCounts;
|
|
2220
|
-
private getBelongsToEntitiesByParentKey;
|
|
2221
|
-
private getMatchingHasManyParentKeys;
|
|
2222
|
-
private getMatchingMorphManyParentKeys;
|
|
2223
|
-
private getHasManyMatchCounts;
|
|
2224
|
-
private getMorphManyMatchCounts;
|
|
2225
|
-
private getMatchingMorphToParentKeys;
|
|
2226
|
-
private getMorphToMatchCounts;
|
|
2227
|
-
private getMatchingThroughParentKeys;
|
|
2228
|
-
private getThroughMatchCounts;
|
|
2229
|
-
private getHasManyEntitiesByParentKey;
|
|
2230
|
-
private getMorphManyEntitiesByParentKey;
|
|
2231
|
-
private getMorphToEntitiesByParentKey;
|
|
2232
|
-
private matchesMorphType;
|
|
2233
|
-
private resolveMorphLoadTargets;
|
|
2234
|
-
private normalizeMorphLoadTargets;
|
|
2235
|
-
private serializeMorphLoadTargets;
|
|
2236
|
-
private selectOneOfManyEntity;
|
|
2237
|
-
private selectMorphOneOfManyEntity;
|
|
2238
|
-
private getThroughEntitiesByParentKey;
|
|
2239
|
-
private getMatchingBelongsToManyParentKeys;
|
|
2240
|
-
private getMatchingMorphToManyParentKeys;
|
|
2241
|
-
private getMatchingMorphedByManyParentKeys;
|
|
2242
|
-
private getBelongsToManyMatchCounts;
|
|
2243
|
-
private getMorphToManyMatchCounts;
|
|
2244
|
-
private getMorphedByManyMatchCounts;
|
|
2245
|
-
private getBelongsToManyEntitiesByParentKey;
|
|
2246
|
-
private getMorphToManyEntitiesByParentKey;
|
|
2247
|
-
private getMorphedByManyEntitiesByParentKey;
|
|
2248
|
-
private createBelongsToManyPivotQuery;
|
|
2249
|
-
private createMorphToManyPivotQuery;
|
|
2250
|
-
private createMorphedByManyPivotQuery;
|
|
2251
|
-
private applyPivotQueryConfig;
|
|
2252
|
-
private attachPivotAttributes;
|
|
2253
|
-
private extractPivotAttributes;
|
|
2254
|
-
private getDefaultPivotColumns;
|
|
2255
|
-
private getPivotMutationContext;
|
|
2256
|
-
private normalizePivotInput;
|
|
2257
|
-
private assertValidPivotEntries;
|
|
2258
|
-
private assertValidPivotAttributes;
|
|
2259
|
-
private getPivotRows;
|
|
2260
|
-
private indexPivotRows;
|
|
2261
|
-
private pivotAttributesChanged;
|
|
2262
|
-
private insertPivotRow;
|
|
2263
|
-
private updatePivotRow;
|
|
2264
|
-
private deletePivotRows;
|
|
2265
|
-
private isWritableColumn;
|
|
2266
|
-
private assertPersistedParentForRelation;
|
|
2267
|
-
private assertRelationSupportsManyWrites;
|
|
2268
|
-
private touchOwners;
|
|
2269
|
-
private resolveCompatibleRelatedRepository;
|
|
2270
|
-
private syncRelationAfterPersistence;
|
|
2271
|
-
private createPivotMutationQuery;
|
|
2272
|
-
private getPivotRelatedIdColumn;
|
|
2273
|
-
private getReservedPivotColumns;
|
|
2274
|
-
private buildPivotInsertPayload;
|
|
2275
|
-
private applyGeneratedUniqueIds;
|
|
2276
|
-
private applyPendingAttributes;
|
|
2277
|
-
private getObserverInstances;
|
|
2278
|
-
private dispatchCancelableEvent;
|
|
2279
|
-
private dispatchEvent;
|
|
2280
|
-
private dispatchSyncEvent;
|
|
2281
|
-
resolveAttribute(key: string, entity: Entity<TTable>, value: unknown): unknown;
|
|
2282
|
-
shouldPreventAccessingMissingAttributes(key: string): boolean;
|
|
2283
|
-
serializeEntity(entity: Entity<TTable>): Record<string, unknown>;
|
|
2284
|
-
private serializeRelationValue;
|
|
2285
|
-
private serializeOutputValue;
|
|
2286
|
-
serializeAttributeValue(key: string, value: unknown): unknown;
|
|
2287
|
-
private normalizeFromStorage;
|
|
2288
|
-
private applyTimestampDefaults;
|
|
2289
|
-
private normalizeForStorage;
|
|
2290
|
-
private applySchemaReadNormalization;
|
|
2291
|
-
private applySchemaWriteNormalization;
|
|
2292
|
-
private getSchemaDialectName;
|
|
2293
|
-
private applyCastGet;
|
|
2294
|
-
private applyCastSet;
|
|
2295
|
-
private resolveCastDefinition;
|
|
2296
|
-
private parseBuiltInCast;
|
|
2297
|
-
private parseVectorValue;
|
|
2298
|
-
private serializeVectorValue;
|
|
2299
|
-
private parseVectorString;
|
|
2300
|
-
private parseVectorDimensions;
|
|
2301
|
-
private formatDateCast;
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
type RuntimeState = {
|
|
2305
|
-
savepointCounter: number;
|
|
2306
|
-
rootTransactionTail: Promise<void>;
|
|
2307
|
-
scheduler: QueryScheduler;
|
|
2308
|
-
};
|
|
2309
|
-
type ScopeState = {
|
|
2310
|
-
kind: TransactionScopeKind;
|
|
2311
|
-
depth: number;
|
|
2312
|
-
savepointName?: string;
|
|
2313
|
-
};
|
|
2314
|
-
type TransactionCallbackState = {
|
|
2315
|
-
afterCommit: TransactionCallback[];
|
|
2316
|
-
afterRollback: TransactionCallback[];
|
|
2317
|
-
};
|
|
2318
|
-
type ContextInternals = {
|
|
2319
|
-
contextId: number;
|
|
2320
|
-
connectionName: string;
|
|
2321
|
-
schemaName?: string;
|
|
2322
|
-
adapter: DriverAdapter;
|
|
2323
|
-
dialect: Dialect;
|
|
2324
|
-
driver: DatabaseDriverName;
|
|
2325
|
-
logger?: DatabaseLogger;
|
|
2326
|
-
security: SecurityPolicy;
|
|
2327
|
-
concurrency: ConcurrencyOptions;
|
|
2328
|
-
schemaRegistry: SchemaRegistry;
|
|
2329
|
-
modelRegistry: ModelRegistry;
|
|
2330
|
-
runtime: RuntimeState;
|
|
2331
|
-
scope: ScopeState;
|
|
2332
|
-
transactionCallbacks?: TransactionCallbackState;
|
|
2333
|
-
};
|
|
2334
|
-
declare class DatabaseContext {
|
|
2335
|
-
private readonly _contextId;
|
|
2336
|
-
private readonly _connectionName;
|
|
2337
|
-
private readonly _schemaName?;
|
|
2338
|
-
private readonly _adapter;
|
|
2339
|
-
private readonly _dialect;
|
|
2340
|
-
private readonly _driver;
|
|
2341
|
-
private readonly _logger?;
|
|
2342
|
-
private readonly _security;
|
|
2343
|
-
private readonly _concurrency;
|
|
2344
|
-
private readonly _schemaRegistry;
|
|
2345
|
-
private readonly _modelRegistry;
|
|
2346
|
-
private readonly _runtime;
|
|
2347
|
-
private readonly _scope;
|
|
2348
|
-
private readonly _transactionCallbacks?;
|
|
2349
|
-
private _migrationService?;
|
|
2350
|
-
private _factoryService?;
|
|
2351
|
-
private _eventService?;
|
|
2352
|
-
constructor(options: DatabaseContextOptions | ContextInternals);
|
|
2353
|
-
initialize(): Promise<void>;
|
|
2354
|
-
disconnect(): Promise<void>;
|
|
2355
|
-
isConnected(): boolean;
|
|
2356
|
-
getDriver(): DatabaseDriverName;
|
|
2357
|
-
getConnectionName(): string;
|
|
2358
|
-
getContextId(): number;
|
|
2359
|
-
getSchemaName(): string | undefined;
|
|
2360
|
-
getAdapter(): DriverAdapter;
|
|
2361
|
-
getDialect(): Dialect;
|
|
2362
|
-
getCapabilities(): DatabaseCapabilities;
|
|
2363
|
-
getSecurityPolicy(): SecurityPolicy;
|
|
2364
|
-
getConcurrencyOptions(): ConcurrencyOptions;
|
|
2365
|
-
getSchemaRegistry(): SchemaRegistry;
|
|
2366
|
-
getModelRegistry(): ModelRegistry;
|
|
2367
|
-
getMigrationService(): MigrationService;
|
|
2368
|
-
getFactoryService(): FactoryService;
|
|
2369
|
-
getEventService(): ModelEventService;
|
|
2370
|
-
registerModel(reference: ModelDefinitionLike): AnyModelDefinition;
|
|
2371
|
-
model(reference: ModelDefinitionLike): ModelRepository;
|
|
2372
|
-
getLogger(): DatabaseLogger | undefined;
|
|
2373
|
-
getScope(): Readonly<ScopeState>;
|
|
2374
|
-
afterCommit(callback: TransactionCallback): void;
|
|
2375
|
-
afterRollback(callback: TransactionCallback): void;
|
|
2376
|
-
getSchedulingModeHint(): 'concurrent' | 'serialized' | 'worker';
|
|
2377
|
-
unsafeQuery<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: UnsafeStatement, options?: DatabaseOperationOptions): Promise<DriverQueryResult<TRow>>;
|
|
2378
|
-
unsafeExecute(statement: UnsafeStatement, options?: DatabaseOperationOptions): Promise<DriverExecutionResult>;
|
|
2379
|
-
queryCompiled<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: CompiledStatement, options?: DatabaseOperationOptions): Promise<DriverQueryResult<TRow>>;
|
|
2380
|
-
introspectCompiled<TRow extends Record<string, unknown> = Record<string, unknown>>(statement: CompiledStatement, options?: DatabaseOperationOptions): Promise<DriverQueryResult<TRow>>;
|
|
2381
|
-
executeCompiled(statement: CompiledStatement, options?: DatabaseOperationOptions): Promise<DriverExecutionResult>;
|
|
2382
|
-
transaction<T>(callback: (tx: DatabaseContext) => Promise<T>, options?: DatabaseOperationOptions): Promise<T>;
|
|
2383
|
-
private _runRootTransaction;
|
|
2384
|
-
private _runSerializedRootTransaction;
|
|
2385
|
-
private _runNestedTransaction;
|
|
2386
|
-
private _createChildContext;
|
|
2387
|
-
private _runTransactionCallback;
|
|
2388
|
-
private _createTransactionCallbackState;
|
|
2389
|
-
private _registerTransactionCallback;
|
|
2390
|
-
private _mergeCommittedTransactionCallbacks;
|
|
2391
|
-
private _flushTransactionCallbacks;
|
|
2392
|
-
private _assertUnsafeRawAllowed;
|
|
2393
|
-
private _assertUnsafeStatement;
|
|
2394
|
-
private _assertCompiledStatementAllowed;
|
|
2395
|
-
private _runLogged;
|
|
2396
|
-
private _wrapDriverError;
|
|
2397
|
-
private _callTransactionHook;
|
|
2398
|
-
private _guardOperation;
|
|
2399
|
-
private _assertValidOperationOptions;
|
|
2400
|
-
private _throwIfAborted;
|
|
2401
|
-
private _createGuardError;
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
type ModelUpdatePayload<TTable extends TableDefinition> = Partial<InferUpdate<TTable>>;
|
|
2405
|
-
type ModelRecord<TTable extends TableDefinition> = InferSelect<TTable>;
|
|
2406
|
-
|
|
2407
|
-
type ModelAttributeKey<TTable extends TableDefinition> = Extract<keyof InferSelect<TTable>, string>;
|
|
2408
|
-
type ModelColumnName<TTable extends TableDefinition> = ModelAttributeKey<TTable> | `${string}.${ModelAttributeKey<TTable>}`;
|
|
2409
|
-
type ModelColumnReference<TTable extends TableDefinition> = ModelColumnName<TTable> | `${string}.${string}`;
|
|
2410
|
-
type ModelJsonColumnPath<TTable extends TableDefinition> = ModelColumnName<TTable> | `${ModelColumnName<TTable>}->${string}`;
|
|
2411
|
-
type ModelSelectableColumn<TTable extends TableDefinition> = ModelColumnName<TTable> | `${ModelColumnName<TTable>} as ${string}`;
|
|
2412
|
-
interface AnyModelDefinition {
|
|
2413
|
-
readonly kind: 'model';
|
|
2414
|
-
readonly table: TableDefinition;
|
|
2415
|
-
readonly name: string;
|
|
2416
|
-
readonly primaryKey: string;
|
|
2417
|
-
readonly connectionName?: string;
|
|
2418
|
-
readonly morphClass: string;
|
|
2419
|
-
readonly with: readonly string[];
|
|
2420
|
-
readonly pendingAttributes: Partial<Record<string, unknown>>;
|
|
2421
|
-
readonly preventLazyLoading: boolean;
|
|
2422
|
-
readonly preventAccessingMissingAttributes: boolean;
|
|
2423
|
-
readonly automaticEagerLoading: boolean;
|
|
2424
|
-
readonly timestamps: boolean;
|
|
2425
|
-
readonly createdAtColumn?: string;
|
|
2426
|
-
readonly updatedAtColumn?: string;
|
|
2427
|
-
readonly fillable: readonly string[];
|
|
2428
|
-
readonly hasExplicitFillable?: boolean;
|
|
2429
|
-
readonly guarded: readonly string[];
|
|
2430
|
-
readonly relations: RelationMap;
|
|
2431
|
-
readonly casts: Record<string, ModelCastDefinition>;
|
|
2432
|
-
readonly accessors: Record<string, ModelAccessor>;
|
|
2433
|
-
readonly mutators: Record<string, ModelMutator>;
|
|
2434
|
-
readonly hidden: readonly string[];
|
|
2435
|
-
readonly visible: readonly string[];
|
|
2436
|
-
readonly appended: readonly string[];
|
|
2437
|
-
readonly serializeDate?: ModelDateSerializer;
|
|
2438
|
-
readonly massPrunable: boolean;
|
|
2439
|
-
readonly touches: readonly string[];
|
|
2440
|
-
readonly replicationExcludes: readonly string[];
|
|
2441
|
-
readonly softDeletes: boolean;
|
|
2442
|
-
readonly deletedAtColumn?: string;
|
|
2443
|
-
readonly events: Partial<Record<ModelLifecycleEventName, readonly ModelLifecycleEventHandler[]>>;
|
|
2444
|
-
readonly observers: readonly unknown[];
|
|
2445
|
-
}
|
|
2446
|
-
interface AnyEntity {
|
|
2447
|
-
getRepository(): {
|
|
2448
|
-
definition: AnyModelDefinition;
|
|
2449
|
-
};
|
|
2450
|
-
toAttributes(): Record<string, unknown>;
|
|
2451
|
-
getChanges(): Record<string, unknown>;
|
|
2452
|
-
}
|
|
2453
|
-
type ModelDefinitionLike<TTable extends TableDefinition = TableDefinition> = (AnyModelDefinition & {
|
|
2454
|
-
readonly table: TTable;
|
|
2455
|
-
}) | {
|
|
2456
|
-
readonly definition: AnyModelDefinition & {
|
|
2457
|
-
readonly table: TTable;
|
|
2458
|
-
};
|
|
2459
|
-
};
|
|
2460
|
-
interface ModelScopeMap<TTable extends TableDefinition = TableDefinition> {
|
|
2461
|
-
readonly [key: string]: (query: ModelQueryBuilder<TTable>, ...args: readonly unknown[]) => ModelQueryBuilder<TTable>;
|
|
2462
|
-
}
|
|
2463
|
-
type RelationConstraintDefinition = (query: ModelQueryBuilder<TableDefinition>) => unknown;
|
|
2464
|
-
interface ScopedRelationDefinition {
|
|
2465
|
-
readonly constraint?: RelationConstraintDefinition;
|
|
2466
|
-
}
|
|
2467
|
-
type ModelDefinitionTable<TReference extends ModelDefinitionLike> = TReference extends {
|
|
2468
|
-
readonly definition: {
|
|
2469
|
-
readonly table: infer TTable extends TableDefinition;
|
|
2470
|
-
};
|
|
2471
|
-
} ? TTable : TReference extends {
|
|
2472
|
-
readonly table: infer TTable extends TableDefinition;
|
|
2473
|
-
} ? TTable : TableDefinition;
|
|
2474
|
-
type PivotTableColumnName<TPivotTable extends string | TableDefinition> = TPivotTable extends TableDefinition ? Extract<keyof InferSelect<TPivotTable>, string> : string;
|
|
2475
|
-
interface BelongsToRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2476
|
-
readonly kind: 'belongsTo';
|
|
2477
|
-
readonly related: () => TRelated;
|
|
2478
|
-
readonly foreignKey: string;
|
|
2479
|
-
readonly ownerKey: string;
|
|
2480
|
-
}
|
|
2481
|
-
interface HasManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2482
|
-
readonly kind: 'hasMany';
|
|
2483
|
-
readonly related: () => TRelated;
|
|
2484
|
-
readonly foreignKey: string;
|
|
2485
|
-
readonly localKey: string;
|
|
2486
|
-
}
|
|
2487
|
-
interface HasOneRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2488
|
-
readonly kind: 'hasOne';
|
|
2489
|
-
readonly related: () => TRelated;
|
|
2490
|
-
readonly foreignKey: string;
|
|
2491
|
-
readonly localKey: string;
|
|
2492
|
-
}
|
|
2493
|
-
interface HasOneOfManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2494
|
-
readonly kind: 'hasOneOfMany';
|
|
2495
|
-
readonly related: () => TRelated;
|
|
2496
|
-
readonly foreignKey: string;
|
|
2497
|
-
readonly localKey: string;
|
|
2498
|
-
readonly aggregateColumn: string;
|
|
2499
|
-
readonly aggregate: 'min' | 'max';
|
|
2500
|
-
}
|
|
2501
|
-
interface MorphOneRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2502
|
-
readonly kind: 'morphOne';
|
|
2503
|
-
readonly related: () => TRelated;
|
|
2504
|
-
readonly morphName: string;
|
|
2505
|
-
readonly morphTypeColumn: string;
|
|
2506
|
-
readonly morphIdColumn: string;
|
|
2507
|
-
readonly localKey: string;
|
|
2508
|
-
}
|
|
2509
|
-
interface MorphManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2510
|
-
readonly kind: 'morphMany';
|
|
2511
|
-
readonly related: () => TRelated;
|
|
2512
|
-
readonly morphName: string;
|
|
2513
|
-
readonly morphTypeColumn: string;
|
|
2514
|
-
readonly morphIdColumn: string;
|
|
2515
|
-
readonly localKey: string;
|
|
2516
|
-
}
|
|
2517
|
-
interface MorphOneOfManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2518
|
-
readonly kind: 'morphOneOfMany';
|
|
2519
|
-
readonly related: () => TRelated;
|
|
2520
|
-
readonly morphName: string;
|
|
2521
|
-
readonly morphTypeColumn: string;
|
|
2522
|
-
readonly morphIdColumn: string;
|
|
2523
|
-
readonly localKey: string;
|
|
2524
|
-
readonly aggregateColumn: string;
|
|
2525
|
-
readonly aggregate: 'min' | 'max';
|
|
2526
|
-
}
|
|
2527
|
-
interface MorphToRelationDefinition<TTable extends TableDefinition = TableDefinition> extends ScopedRelationDefinition {
|
|
2528
|
-
readonly kind: 'morphTo';
|
|
2529
|
-
readonly morphName: string;
|
|
2530
|
-
readonly morphTypeColumn: string;
|
|
2531
|
-
readonly morphIdColumn: string;
|
|
2532
|
-
}
|
|
2533
|
-
interface BelongsToManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike, TPivotTable extends string | TableDefinition = string | TableDefinition> extends ScopedRelationDefinition, PivotRelationMethods<BelongsToManyRelationDefinition<TRelated, TPivotTable>, TPivotTable> {
|
|
2534
|
-
readonly kind: 'belongsToMany';
|
|
2535
|
-
readonly related: () => TRelated;
|
|
2536
|
-
readonly pivotTable: TPivotTable;
|
|
2537
|
-
readonly foreignPivotKey: string;
|
|
2538
|
-
readonly relatedPivotKey: string;
|
|
2539
|
-
readonly parentKey: string;
|
|
2540
|
-
readonly relatedKey: string;
|
|
2541
|
-
readonly pivotColumns: readonly PivotTableColumnName<TPivotTable>[];
|
|
2542
|
-
readonly pivotWheres: readonly PivotWhereDefinition[];
|
|
2543
|
-
readonly pivotOrderBy: readonly PivotOrderDefinition[];
|
|
2544
|
-
readonly pivotAccessor: string;
|
|
2545
|
-
readonly pivotModel?: () => ModelDefinitionLike;
|
|
2546
|
-
}
|
|
2547
|
-
interface MorphToManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike, TPivotTable extends string | TableDefinition = string | TableDefinition> extends ScopedRelationDefinition, PivotRelationMethods<MorphToManyRelationDefinition<TRelated, TPivotTable>, TPivotTable> {
|
|
2548
|
-
readonly kind: 'morphToMany';
|
|
2549
|
-
readonly related: () => TRelated;
|
|
2550
|
-
readonly pivotTable: TPivotTable;
|
|
2551
|
-
readonly morphName: string;
|
|
2552
|
-
readonly morphTypeColumn: string;
|
|
2553
|
-
readonly morphIdColumn: string;
|
|
2554
|
-
readonly foreignPivotKey: string;
|
|
2555
|
-
readonly parentKey: string;
|
|
2556
|
-
readonly relatedKey: string;
|
|
2557
|
-
readonly pivotColumns: readonly PivotTableColumnName<TPivotTable>[];
|
|
2558
|
-
readonly pivotWheres: readonly PivotWhereDefinition[];
|
|
2559
|
-
readonly pivotOrderBy: readonly PivotOrderDefinition[];
|
|
2560
|
-
readonly pivotAccessor: string;
|
|
2561
|
-
readonly pivotModel?: () => ModelDefinitionLike;
|
|
2562
|
-
}
|
|
2563
|
-
interface MorphedByManyRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike, TPivotTable extends string | TableDefinition = string | TableDefinition> extends ScopedRelationDefinition, PivotRelationMethods<MorphedByManyRelationDefinition<TRelated, TPivotTable>, TPivotTable> {
|
|
2564
|
-
readonly kind: 'morphedByMany';
|
|
2565
|
-
readonly related: () => TRelated;
|
|
2566
|
-
readonly pivotTable: TPivotTable;
|
|
2567
|
-
readonly morphName: string;
|
|
2568
|
-
readonly morphTypeColumn: string;
|
|
2569
|
-
readonly morphIdColumn: string;
|
|
2570
|
-
readonly foreignPivotKey: string;
|
|
2571
|
-
readonly parentKey: string;
|
|
2572
|
-
readonly relatedKey: string;
|
|
2573
|
-
readonly pivotColumns: readonly PivotTableColumnName<TPivotTable>[];
|
|
2574
|
-
readonly pivotWheres: readonly PivotWhereDefinition[];
|
|
2575
|
-
readonly pivotOrderBy: readonly PivotOrderDefinition[];
|
|
2576
|
-
readonly pivotAccessor: string;
|
|
2577
|
-
readonly pivotModel?: () => ModelDefinitionLike;
|
|
2578
|
-
}
|
|
2579
|
-
interface PivotWhereDefinition {
|
|
2580
|
-
readonly column: string;
|
|
2581
|
-
readonly operator: string;
|
|
2582
|
-
readonly value: unknown;
|
|
2583
|
-
}
|
|
2584
|
-
interface PivotOrderDefinition {
|
|
2585
|
-
readonly column: string;
|
|
2586
|
-
readonly direction: 'asc' | 'desc';
|
|
2587
|
-
}
|
|
2588
|
-
interface PivotRelationMethods<TRelation, TPivotTable extends string | TableDefinition = string | TableDefinition> {
|
|
2589
|
-
withPivot(...columns: readonly PivotTableColumnName<TPivotTable>[]): TRelation;
|
|
2590
|
-
wherePivot(column: PivotTableColumnName<TPivotTable>, operator: unknown, value?: unknown): TRelation;
|
|
2591
|
-
orderByPivot(column: PivotTableColumnName<TPivotTable>, direction?: 'asc' | 'desc'): TRelation;
|
|
2592
|
-
as(accessor: string): TRelation;
|
|
2593
|
-
using(model: () => ModelDefinitionLike): TRelation;
|
|
2594
|
-
}
|
|
2595
|
-
interface HasOneThroughRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike, TThrough extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2596
|
-
readonly kind: 'hasOneThrough';
|
|
2597
|
-
readonly related: () => TRelated;
|
|
2598
|
-
readonly through: () => TThrough;
|
|
2599
|
-
readonly firstKey: string;
|
|
2600
|
-
readonly secondKey: string;
|
|
2601
|
-
readonly localKey: string;
|
|
2602
|
-
readonly secondLocalKey: string;
|
|
2603
|
-
}
|
|
2604
|
-
interface HasManyThroughRelationDefinition<TRelated extends ModelDefinitionLike = ModelDefinitionLike, TThrough extends ModelDefinitionLike = ModelDefinitionLike> extends ScopedRelationDefinition {
|
|
2605
|
-
readonly kind: 'hasManyThrough';
|
|
2606
|
-
readonly related: () => TRelated;
|
|
2607
|
-
readonly through: () => TThrough;
|
|
2608
|
-
readonly firstKey: string;
|
|
2609
|
-
readonly secondKey: string;
|
|
2610
|
-
readonly localKey: string;
|
|
2611
|
-
readonly secondLocalKey: string;
|
|
2612
|
-
}
|
|
2613
|
-
type RelationDefinition = BelongsToRelationDefinition | HasManyRelationDefinition | HasOneRelationDefinition | HasOneOfManyRelationDefinition | MorphOneRelationDefinition | MorphManyRelationDefinition | MorphOneOfManyRelationDefinition | MorphToRelationDefinition | BelongsToManyRelationDefinition | MorphToManyRelationDefinition | MorphedByManyRelationDefinition | HasOneThroughRelationDefinition | HasManyThroughRelationDefinition;
|
|
2614
|
-
/**
|
|
2615
|
-
* Methods available on BelongsTo relations when called as a method (e.g., post.category())
|
|
2616
|
-
*/
|
|
2617
|
-
interface BelongsToRelationMethods<TRelated> {
|
|
2618
|
-
associate(related: TRelated | null): void;
|
|
2619
|
-
dissociate(): void;
|
|
2620
|
-
}
|
|
2621
|
-
/**
|
|
2622
|
-
* Methods available on HasOne/HasOneThrough relations when called as a method
|
|
2623
|
-
*/
|
|
2624
|
-
interface HasOneRelationMethods<TRelated> {
|
|
2625
|
-
create(values: Record<string, unknown>): Promise<TRelated>;
|
|
2626
|
-
save(related: TRelated): Promise<TRelated>;
|
|
2627
|
-
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Methods available on HasMany/HasManyThrough relations when called as a method
|
|
2630
|
-
*/
|
|
2631
|
-
interface HasManyRelationMethods<TRelated> {
|
|
2632
|
-
create(values: Record<string, unknown>): Promise<TRelated>;
|
|
2633
|
-
createMany(values: readonly Record<string, unknown>[]): Promise<TRelated[]>;
|
|
2634
|
-
save(related: TRelated): Promise<TRelated>;
|
|
2635
|
-
saveMany(related: readonly TRelated[]): Promise<TRelated[]>;
|
|
2636
|
-
}
|
|
2637
|
-
/**
|
|
2638
|
-
* Methods available on BelongsToMany relations when called as a method (e.g., post.tags())
|
|
2639
|
-
*/
|
|
2640
|
-
interface BelongsToManyRelationMethods<TRelated, TPivot = Record<string, unknown>> {
|
|
2641
|
-
attach(ids: unknown | readonly unknown[], attributes?: TPivot): Promise<void>;
|
|
2642
|
-
detach(ids?: unknown | readonly unknown[]): Promise<number>;
|
|
2643
|
-
sync(ids: unknown): Promise<{
|
|
2644
|
-
attached: unknown[];
|
|
2645
|
-
detached: unknown[];
|
|
2646
|
-
updated: unknown[];
|
|
2647
|
-
}>;
|
|
2648
|
-
toggle(ids: unknown): Promise<{
|
|
2649
|
-
attached: unknown[];
|
|
2650
|
-
detached: unknown[];
|
|
2651
|
-
}>;
|
|
2652
|
-
updateExistingPivot(id: unknown, attributes: TPivot): Promise<number>;
|
|
2653
|
-
create(values: Record<string, unknown>): Promise<TRelated>;
|
|
2654
|
-
save(related: TRelated): Promise<TRelated>;
|
|
2655
|
-
}
|
|
2656
|
-
/**
|
|
2657
|
-
* Converts a RelationDefinition to its corresponding methods type
|
|
2658
|
-
*/
|
|
2659
|
-
type RelationMethodsOf<TRelation extends RelationDefinition> = TRelation extends BelongsToRelationDefinition<infer TRelated> ? BelongsToRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends HasOneRelationDefinition<infer TRelated> ? HasOneRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends HasOneOfManyRelationDefinition<infer TRelated> ? HasOneRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends HasManyRelationDefinition<infer TRelated> ? HasManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends HasOneThroughRelationDefinition<infer TRelated> ? HasOneRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends HasManyThroughRelationDefinition<infer TRelated> ? HasManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends BelongsToManyRelationDefinition<infer TRelated> ? BelongsToManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>, Record<string, unknown>> : TRelation extends MorphOneRelationDefinition<infer TRelated> ? HasOneRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends MorphOneOfManyRelationDefinition<infer TRelated> ? HasOneRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends MorphManyRelationDefinition<infer TRelated> ? HasManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>> : TRelation extends MorphToManyRelationDefinition<infer TRelated> ? BelongsToManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>, Record<string, unknown>> : TRelation extends MorphedByManyRelationDefinition<infer TRelated> ? BelongsToManyRelationMethods<Entity<ModelDefinitionTable<TRelated>>, Record<string, unknown>> : never;
|
|
2660
|
-
interface RelationMap {
|
|
2661
|
-
readonly [key: string]: RelationDefinition;
|
|
2662
|
-
}
|
|
2663
|
-
type ModelRelationName<TRelations extends RelationMap = RelationMap> = Extract<keyof TRelations, string>;
|
|
2664
|
-
type ModelRelationPath<TRelations extends RelationMap = RelationMap> = InternalRelationPath<TRelations, 15>;
|
|
2665
|
-
type InternalRelationPath<TRelations extends RelationMap, TDepth extends number> = ModelRelationName<TRelations> | NestedRelationPath<TRelations, TDepth>;
|
|
2666
|
-
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
|
|
2667
|
-
type NestedRelationPath<TRelations extends RelationMap, TDepth extends number> = TDepth extends 0 ? never : string extends ModelRelationName<TRelations> ? `${string}.${string}` : {
|
|
2668
|
-
[K in ModelRelationName<TRelations>]: TRelations[K] extends {
|
|
2669
|
-
readonly kind: 'morphTo';
|
|
2670
|
-
} ? `${K}.${string}` : TRelations[K] extends {
|
|
2671
|
-
readonly related: () => infer TRef;
|
|
2672
|
-
} ? `${K}.${InternalRelationPath<RelatedRelationsOfDefinition<TRef>, Prev[TDepth]>}` : never;
|
|
2673
|
-
}[ModelRelationName<TRelations>];
|
|
2674
|
-
type RelationRootName<TRelations extends RelationMap, TRelationPath extends ModelRelationPath<TRelations>> = TRelationPath extends `${infer TRoot}.${string}` ? TRoot extends ModelRelationName<TRelations> ? TRoot : never : TRelationPath extends ModelRelationName<TRelations> ? TRelationPath : never;
|
|
2675
|
-
type RelatedTableOfRelation<TRelation extends RelationDefinition> = TRelation extends {
|
|
2676
|
-
readonly related: () => infer TReference extends ModelDefinitionLike;
|
|
2677
|
-
} ? ModelDefinitionTable<TReference> : TableDefinition;
|
|
2678
|
-
type RelatedColumnNameOfRelation<TRelation extends RelationDefinition> = ModelAttributeKey<RelatedTableOfRelation<TRelation>>;
|
|
2679
|
-
type RelatedColumnNameForRelationPath<TRelations extends RelationMap, TRelationPath extends ModelRelationPath<TRelations>> = RelatedColumnNameOfRelation<TRelations[RelationRootName<TRelations, TRelationPath>]>;
|
|
2680
|
-
/**
|
|
2681
|
-
* Extracts the RelationMap from a related model definition referenced by a
|
|
2682
|
-
* relation. This enables recursive type resolution for nested eager loads
|
|
2683
|
-
* like `'posts.comments'`.
|
|
2684
|
-
*/
|
|
2685
|
-
type RelatedRelationsOfDefinition<TRef> = TRef extends {
|
|
2686
|
-
readonly relations: infer R extends RelationMap;
|
|
2687
|
-
} ? R : TRef extends {
|
|
2688
|
-
readonly definition: {
|
|
2689
|
-
readonly relations: infer R extends RelationMap;
|
|
2690
|
-
};
|
|
2691
|
-
} ? R : RelationMap;
|
|
2692
|
-
type RelatedRelationsOfRelation<TRelation extends RelationDefinition> = TRelation extends {
|
|
2693
|
-
readonly related: () => infer TRef;
|
|
2694
|
-
} ? RelatedRelationsOfDefinition<TRef> : RelationMap;
|
|
2695
|
-
/** True for relation kinds that resolve to an array of entities. */
|
|
2696
|
-
type IsToManyRelation<TRelation extends RelationDefinition> = TRelation extends {
|
|
2697
|
-
readonly kind: 'hasMany' | 'belongsToMany' | 'morphMany' | 'morphToMany' | 'morphedByMany' | 'hasManyThrough';
|
|
2698
|
-
} ? true : false;
|
|
2699
|
-
/** Resolves a single (non-nested) relation to its typed entity shape. */
|
|
2700
|
-
type ResolveRelationEntity<TRelation extends RelationDefinition> = Entity<RelatedTableOfRelation<TRelation>, RelatedRelationsOfRelation<TRelation>>;
|
|
2701
|
-
type ResolveNestedRelationEntity<TRelation extends RelationDefinition, TLoaded> = EntityWithLoaded<RelatedTableOfRelation<TRelation>, RelatedRelationsOfRelation<TRelation>, TLoaded>;
|
|
2702
|
-
/**
|
|
2703
|
-
* Wraps a base entity type in the correct cardinality for a relation:
|
|
2704
|
-
* - to-many → `TEntity[]`
|
|
2705
|
-
* - to-one → `TEntity | null`
|
|
2706
|
-
*/
|
|
2707
|
-
type WrapRelationCardinality<TRelation extends RelationDefinition, TEntity> = IsToManyRelation<TRelation> extends true ? TEntity[] : TEntity | null;
|
|
2708
|
-
/**
|
|
2709
|
-
* Recursively resolves a dot-separated eager-load path against a RelationMap.
|
|
2710
|
-
*
|
|
2711
|
-
* - `'posts'` → `{ posts: Entity<PostsTable>[] }`
|
|
2712
|
-
* - `'posts.comments'` → `{ posts: (Entity<PostsTable> & { comments: Entity<CommentsTable>[] })[] }`
|
|
2713
|
-
* - `'profile'` → `{ profile: Entity<ProfileTable> | null }`
|
|
2714
|
-
*
|
|
2715
|
-
* Depth is bounded by TS's recursion limit (~25), but real-world nesting
|
|
2716
|
-
* rarely exceeds 3-4 levels.
|
|
2717
|
-
*/
|
|
2718
|
-
type ResolveEagerLoadPath<TRelations extends RelationMap, TPath extends string> = string extends TPath ? unknown : TPath extends `${infer TRoot}.${infer TRest}` ? TRoot extends keyof TRelations & string ? TRelations[TRoot] extends {
|
|
2719
|
-
readonly kind: 'morphTo';
|
|
2720
|
-
} ? {
|
|
2721
|
-
readonly [K in TRoot]: WrapRelationCardinality<TRelations[TRoot], ResolveRelationEntity<TRelations[TRoot]>>;
|
|
2722
|
-
} : {
|
|
2723
|
-
readonly [K in TRoot]: WrapRelationCardinality<TRelations[TRoot], ResolveNestedRelationEntity<TRelations[TRoot], ResolveEagerLoadPath<RelatedRelationsOfRelation<TRelations[TRoot]>, TRest>>>;
|
|
2724
|
-
} : never : TPath extends keyof TRelations & string ? {
|
|
2725
|
-
readonly [K in TPath]: WrapRelationCardinality<TRelations[TPath], ResolveRelationEntity<TRelations[TPath]>>;
|
|
2726
|
-
} : never;
|
|
2727
|
-
/**
|
|
2728
|
-
* Merges multiple eager-load paths into a single intersection type.
|
|
2729
|
-
* Used by `with()` and `load()` to accumulate loaded relation shapes.
|
|
2730
|
-
*/
|
|
2731
|
-
type ResolveEagerLoads<TRelations extends RelationMap, TPaths extends readonly string[]> = TPaths extends readonly [] ? unknown : TPaths extends readonly [infer TFirst extends string, ...infer TRest extends readonly string[]] ? ResolveEagerLoadPath<TRelations, TFirst> & ResolveEagerLoads<TRelations, TRest> : ResolveEagerLoadUnion<TRelations, TPaths[number]>;
|
|
2732
|
-
/**
|
|
2733
|
-
* Converts a union to an intersection via distributive conditional types.
|
|
2734
|
-
* `A | B` → `A & B`
|
|
2735
|
-
*/
|
|
2736
|
-
type UnionToIntersection<TUnion> = (TUnion extends unknown ? (x: TUnion) => void : never) extends (x: infer TIntersection) => void ? TIntersection : never;
|
|
2737
|
-
/**
|
|
2738
|
-
* Resolves a union of eager-load paths into an intersection of their
|
|
2739
|
-
* resolved shapes. Used by the object-form `with()` overload where
|
|
2740
|
-
* the paths come from `keyof TMap` (a union, not a tuple).
|
|
2741
|
-
*/
|
|
2742
|
-
type ResolveEagerLoadUnion<TRelations extends RelationMap, TPaths extends string> = UnionToIntersection<TPaths extends unknown ? ResolveEagerLoadPath<TRelations, TPaths> : never>;
|
|
2743
|
-
/**
|
|
2744
|
-
* Recursively converts an eager-loaded shape from entity types to their
|
|
2745
|
-
* serialized (JSON) form. Replaces `Entity<T>` with `ModelRecord<T>` and
|
|
2746
|
-
* recurses into nested loaded relations.
|
|
2747
|
-
*
|
|
2748
|
-
* - `Entity<T>[]` → `ModelRecord<T>[]`
|
|
2749
|
-
* - `Entity<T> | null` → `ModelRecord<T> | null`
|
|
2750
|
-
* - `Entity<T> & { r: Entity<U>[] }` → `ModelRecord<T> & { r: ModelRecord<U>[] }`
|
|
2751
|
-
*/
|
|
2752
|
-
type SerializeLoadedValue<TValue> = TValue extends readonly (infer TItem)[] ? SerializeLoadedValue<TItem>[] : TValue extends null ? null : TValue extends Entity<infer TTable, infer _TRelations> ? ModelRecord<TTable> & SerializeLoaded<Omit<TValue, keyof Entity<TTable, _TRelations>>> : TValue;
|
|
2753
|
-
type SerializeLoaded<TLoaded> = unknown extends TLoaded ? unknown : {
|
|
2754
|
-
readonly [K in keyof TLoaded]: SerializeLoadedValue<TLoaded[K]>;
|
|
2755
|
-
};
|
|
2756
|
-
/**
|
|
2757
|
-
* The serialized (JSON) form of an entity with eager-loaded relations.
|
|
2758
|
-
* This is the return type of `toJSON()` when called on an entity that
|
|
2759
|
-
* has loaded relations via `with()` or `load()`.
|
|
2760
|
-
*/
|
|
2761
|
-
type SerializedEntityWithLoaded<TTable extends TableDefinition, TLoaded> = ModelRecord<TTable> & SerializeLoaded<TLoaded>;
|
|
2762
|
-
/**
|
|
2763
|
-
* The entity type returned by terminal query methods when eager loads
|
|
2764
|
-
* have been accumulated via `with()`.
|
|
2765
|
-
*/
|
|
2766
|
-
type EntityWithLoaded<TTable extends TableDefinition, TRelations extends RelationMap, TLoaded> = ModelBase<TTable, TRelations> & Omit<ModelRelationMethods<TRelations>, Extract<keyof TLoaded, string>> & TLoaded & {
|
|
2767
|
-
toJSON(): SerializedEntityWithLoaded<TTable, TLoaded>;
|
|
2768
|
-
};
|
|
2769
|
-
type EmptyScopeMap = Record<never, never>;
|
|
2770
|
-
type ModelScopesDefinition = Readonly<Record<string, unknown>>;
|
|
2771
|
-
type ModelLifecycleEventName = 'retrieved' | 'creating' | 'created' | 'updating' | 'updated' | 'saving' | 'saved' | 'deleting' | 'trashed' | 'forceDeleting' | 'forceDeleted' | 'restoring' | 'restored' | 'deleted' | 'replicating';
|
|
2772
|
-
type ModelLifecycleEventHandler = (...args: readonly unknown[]) => unknown | Promise<unknown>;
|
|
2773
|
-
type BuiltInCastName = 'boolean' | 'number' | 'string' | 'json' | 'date' | 'datetime' | 'timestamp' | 'vector';
|
|
2774
|
-
type BuiltInCastString = BuiltInCastName | `${BuiltInCastName}:${string}`;
|
|
2775
|
-
type UniqueIdTraitKind = 'uuid' | 'ulid' | 'snowflake' | 'custom';
|
|
2776
|
-
type RelationAggregateKind = 'count' | 'exists' | 'sum' | 'avg' | 'min' | 'max';
|
|
2777
|
-
interface EnumCastDefinition {
|
|
2778
|
-
readonly kind: 'enum';
|
|
2779
|
-
readonly enumObject: Readonly<Record<string, string | number>>;
|
|
2780
|
-
readonly values: readonly (string | number)[];
|
|
2781
|
-
}
|
|
2782
|
-
interface CastableDefinition {
|
|
2783
|
-
castUsing(): ModelCastDefinition;
|
|
2784
|
-
}
|
|
2785
|
-
type ModelCastDefinition = BuiltInCastString | EnumCastDefinition | CastableDefinition | {
|
|
2786
|
-
get?: (value: unknown) => unknown;
|
|
2787
|
-
set?: (value: unknown) => unknown;
|
|
2788
|
-
};
|
|
2789
|
-
type ModelAccessor = (value: unknown, entity: AnyEntity) => unknown;
|
|
2790
|
-
type ModelMutator = (value: unknown, entity?: AnyEntity) => unknown;
|
|
2791
|
-
type ModelDateSerializer = (value: Date) => unknown;
|
|
2792
|
-
type ModelCollectionFactory<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap> = <TItem extends Entity<TTable, TRelations>>(items: readonly TItem[]) => ModelCollection<TTable, TRelations, TItem>;
|
|
2793
|
-
type ModelPrunableDefinition<TTable extends TableDefinition = TableDefinition, TRelations extends RelationMap = RelationMap> = (query: ModelQueryBuilder<TTable, TRelations>) => unknown;
|
|
2794
|
-
interface UniqueIdTrait<TTable extends TableDefinition = TableDefinition> {
|
|
2795
|
-
readonly kind: 'uniqueIds';
|
|
2796
|
-
readonly name: string;
|
|
2797
|
-
readonly type: UniqueIdTraitKind;
|
|
2798
|
-
readonly columns?: readonly ModelAttributeKey<TTable>[];
|
|
2799
|
-
readonly generator?: () => string;
|
|
2800
|
-
}
|
|
2801
|
-
type ModelTrait<TTable extends TableDefinition = TableDefinition> = UniqueIdTrait<TTable>;
|
|
2802
|
-
interface UniqueIdRuntimeConfig<TTable extends TableDefinition = TableDefinition> {
|
|
2803
|
-
readonly usesUniqueIds: boolean;
|
|
2804
|
-
readonly columns: readonly ModelAttributeKey<TTable>[];
|
|
2805
|
-
readonly generator: () => string;
|
|
2806
|
-
readonly traitName: string;
|
|
2807
|
-
readonly traitType: UniqueIdTraitKind;
|
|
2808
|
-
}
|
|
2809
|
-
interface ModelDefinition<TTable extends TableDefinition = TableDefinition, TScopes extends ModelScopesDefinition = EmptyScopeMap, TRelations extends RelationMap = RelationMap> {
|
|
2810
|
-
readonly kind: 'model';
|
|
2811
|
-
readonly table: TTable;
|
|
2812
|
-
readonly name: string;
|
|
2813
|
-
readonly primaryKey: ModelAttributeKey<TTable>;
|
|
2814
|
-
readonly connectionName?: string;
|
|
2815
|
-
readonly morphClass: string;
|
|
2816
|
-
readonly with: readonly string[];
|
|
2817
|
-
readonly pendingAttributes: Partial<InferInsert<TTable>>;
|
|
2818
|
-
readonly preventLazyLoading: boolean;
|
|
2819
|
-
readonly preventAccessingMissingAttributes: boolean;
|
|
2820
|
-
readonly automaticEagerLoading: boolean;
|
|
2821
|
-
readonly timestamps: boolean;
|
|
2822
|
-
readonly createdAtColumn?: ModelAttributeKey<TTable>;
|
|
2823
|
-
readonly updatedAtColumn?: ModelAttributeKey<TTable>;
|
|
2824
|
-
readonly fillable: readonly string[];
|
|
2825
|
-
readonly hasExplicitFillable?: boolean;
|
|
2826
|
-
readonly guarded: readonly string[];
|
|
2827
|
-
readonly scopes: TScopes;
|
|
2828
|
-
readonly globalScopes: ModelScopeMap<TTable>;
|
|
2829
|
-
readonly relations: TRelations;
|
|
2830
|
-
readonly casts: Record<string, ModelCastDefinition>;
|
|
2831
|
-
readonly accessors: Record<string, ModelAccessor>;
|
|
2832
|
-
readonly mutators: Record<string, ModelMutator>;
|
|
2833
|
-
readonly hidden: readonly string[];
|
|
2834
|
-
readonly visible: readonly string[];
|
|
2835
|
-
readonly appended: readonly string[];
|
|
2836
|
-
readonly serializeDate?: ModelDateSerializer;
|
|
2837
|
-
readonly collection?: ModelCollectionFactory<TTable>;
|
|
2838
|
-
readonly prunable?: ModelPrunableDefinition<TTable>;
|
|
2839
|
-
readonly massPrunable: boolean;
|
|
2840
|
-
readonly touches: readonly string[];
|
|
2841
|
-
readonly traits: readonly ModelTrait<TTable>[];
|
|
2842
|
-
readonly uniqueIdConfig: UniqueIdRuntimeConfig<TTable> | null;
|
|
2843
|
-
readonly replicationExcludes: readonly string[];
|
|
2844
|
-
readonly softDeletes: boolean;
|
|
2845
|
-
readonly deletedAtColumn?: ModelAttributeKey<TTable>;
|
|
2846
|
-
readonly events: Partial<Record<ModelLifecycleEventName, readonly ModelLifecycleEventHandler[]>>;
|
|
2847
|
-
readonly observers: readonly unknown[];
|
|
2848
|
-
}
|
|
2849
|
-
interface ModelReference<TTable extends TableDefinition = TableDefinition, TScopes extends ModelScopesDefinition = EmptyScopeMap, TRelations extends RelationMap = RelationMap> {
|
|
2850
|
-
readonly definition: ModelDefinition<TTable, TScopes, TRelations>;
|
|
2851
|
-
}
|
|
2852
|
-
type ModelMorphLoadMap = Readonly<Record<string, string | readonly string[] | Readonly<Record<string, RelationConstraintDefinition>>>>;
|
|
2853
|
-
interface ModelRepositoryLike<TTable extends TableDefinition = TableDefinition, TScopes extends ModelScopesDefinition = EmptyScopeMap, TRelations extends RelationMap = RelationMap> {
|
|
2854
|
-
readonly definition: ModelDefinition<TTable, TScopes, TRelations>;
|
|
2855
|
-
getConnection(): DatabaseContext;
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
99
|
type MediaModelDefinitionRef = {
|
|
2859
100
|
readonly name: string;
|
|
2860
101
|
readonly morphClass?: string;
|
|
@@ -2910,12 +151,12 @@ interface MediaPathGenerator {
|
|
|
2910
151
|
conversionPath<TCollectionName extends string = string, TConversionName extends string = string>(input: MediaConversionPathInput<TCollectionName, TConversionName>): string;
|
|
2911
152
|
}
|
|
2912
153
|
declare function registerMediaDefinition(target: MediaModelReferenceLike, definition: NormalizedMediaDefinition): NormalizedMediaDefinition;
|
|
2913
|
-
declare function getMediaDefinition(target: MediaModelReferenceLike | Entity
|
|
2914
|
-
declare function requireMediaDefinition(target: MediaModelReferenceLike | Entity
|
|
154
|
+
declare function getMediaDefinition(target: MediaModelReferenceLike | Entity<TableDefinition>): NormalizedMediaDefinition | undefined;
|
|
155
|
+
declare function requireMediaDefinition(target: MediaModelReferenceLike | Entity<TableDefinition>): NormalizedMediaDefinition;
|
|
2915
156
|
declare function getMediaDefinitionForMorphClass(morphClass: string): NormalizedMediaDefinition | undefined;
|
|
2916
157
|
declare function requireMediaDefinitionForMorphClass(morphClass: string): NormalizedMediaDefinition;
|
|
2917
|
-
declare function resolveMediaCollection(target: MediaModelReferenceLike | Entity
|
|
2918
|
-
declare function resolveMediaConversion(target: MediaModelReferenceLike | Entity
|
|
158
|
+
declare function resolveMediaCollection(target: MediaModelReferenceLike | Entity<TableDefinition>, collectionName?: string): NormalizedMediaCollectionDefinition;
|
|
159
|
+
declare function resolveMediaConversion(target: MediaModelReferenceLike | Entity<TableDefinition>, conversionName: string): NormalizedMediaConversionDefinition | undefined;
|
|
2919
160
|
declare function setMediaPathGenerator(generator: MediaPathGenerator): void;
|
|
2920
161
|
declare function resetMediaPathGenerator(): void;
|
|
2921
162
|
declare function getMediaPathGenerator(): MediaPathGenerator;
|
|
@@ -2942,20 +183,20 @@ declare const Media: _holo_js_db.StaticModelApi<_holo_js_db.BoundTableDefinition
|
|
|
2942
183
|
created_at: _holo_js_db.ColumnBuilder<Date, false, true, false, false>;
|
|
2943
184
|
updated_at: _holo_js_db.ColumnBuilder<Date, false, true, false, false>;
|
|
2944
185
|
}>, _holo_js_db.EmptyScopeMap, {
|
|
2945
|
-
model: MorphToRelationDefinition<_holo_js_db.TableDefinition<string, _holo_js_db.TableColumnsShape>>;
|
|
186
|
+
model: _holo_js_db.MorphToRelationDefinition<_holo_js_db.TableDefinition<string, _holo_js_db.TableColumnsShape>>;
|
|
2946
187
|
}>;
|
|
2947
188
|
|
|
2948
|
-
type MediaRecord = ModelRecord
|
|
2949
|
-
declare class MediaItem<TCollectionName extends string = string, TConversionName extends string = string, TEntity extends Entity
|
|
189
|
+
type MediaRecord = ModelRecord<typeof Media.definition.table>;
|
|
190
|
+
declare class MediaItem<TCollectionName extends string = string, TConversionName extends string = string, TEntity extends Entity<TableDefinition> = Entity<TableDefinition>> {
|
|
2950
191
|
private readonly entity;
|
|
2951
192
|
private readonly owner?;
|
|
2952
|
-
constructor(entity: Entity
|
|
193
|
+
constructor(entity: Entity<typeof Media.definition.table>, owner?: TEntity | undefined);
|
|
2953
194
|
get record(): MediaRecord;
|
|
2954
195
|
get collectionName(): TCollectionName;
|
|
2955
196
|
get fileName(): string;
|
|
2956
197
|
get mimeType(): string | null;
|
|
2957
198
|
get size(): number;
|
|
2958
|
-
getEntity(): Entity
|
|
199
|
+
getEntity(): Entity<typeof Media.definition.table>;
|
|
2959
200
|
getAvailableConversions(): readonly TConversionName[];
|
|
2960
201
|
getPath(conversion?: TConversionName): string | null;
|
|
2961
202
|
getUrl(conversion?: TConversionName): string | null;
|
|
@@ -2997,11 +238,11 @@ type MediaAddError = {
|
|
|
2997
238
|
readonly extension?: string;
|
|
2998
239
|
readonly acceptedExtensions?: readonly string[];
|
|
2999
240
|
};
|
|
3000
|
-
type MediaAddResult<TCollectionName extends string = string, TConversionName extends string = string, TEntity extends Entity
|
|
241
|
+
type MediaAddResult<TCollectionName extends string = string, TConversionName extends string = string, TEntity extends Entity<TableDefinition> = Entity<TableDefinition>> = MediaItem<TCollectionName, TConversionName, TEntity> & {
|
|
3001
242
|
readonly data: MediaItem<TCollectionName, TConversionName, TEntity> | null;
|
|
3002
243
|
readonly error: MediaAddError | null;
|
|
3003
244
|
};
|
|
3004
|
-
declare class MediaAdder<TEntity extends Entity
|
|
245
|
+
declare class MediaAdder<TEntity extends Entity<TableDefinition> = Entity<TableDefinition>, TCollectionName extends string = string, TConversionName extends string = string> {
|
|
3005
246
|
private readonly entity;
|
|
3006
247
|
private readonly source;
|
|
3007
248
|
private readonly state;
|
|
@@ -3019,14 +260,14 @@ declare class MediaAdder<TEntity extends Entity$1<TableDefinition$1> = Entity$1<
|
|
|
3019
260
|
|
|
3020
261
|
type MediaCollectionName<TDefinition extends MediaDefinitionInput> = 'default' | CollectionNamesOf<TDefinition>;
|
|
3021
262
|
type MediaConversionName<TDefinition extends MediaDefinitionInput> = ConversionNamesOf<TDefinition>;
|
|
3022
|
-
type MediaEnabledEntity<TTable extends TableDefinition
|
|
263
|
+
type MediaEnabledEntity<TTable extends TableDefinition = TableDefinition, TCollectionName extends string = string, TConversionName extends string = string, TRelations extends RelationMap = RelationMap> = Entity<TTable, TRelations> & MediaEnabledEntityMethods<TCollectionName, TConversionName>;
|
|
3023
264
|
type MediaEnabledEntityMethods<TCollectionName extends string, TConversionName extends string> = {
|
|
3024
|
-
addMedia(source: MediaSourceInput): MediaAdder<Entity
|
|
3025
|
-
addMediaFromUrl(url: string): MediaAdder<Entity
|
|
3026
|
-
getMedia(collectionName?: TCollectionName): Promise<MediaItem<TCollectionName, TConversionName, Entity
|
|
265
|
+
addMedia(source: MediaSourceInput): MediaAdder<Entity<TableDefinition>, TCollectionName, TConversionName>;
|
|
266
|
+
addMediaFromUrl(url: string): MediaAdder<Entity<TableDefinition>, TCollectionName, TConversionName>;
|
|
267
|
+
getMedia(collectionName?: TCollectionName): Promise<MediaItem<TCollectionName, TConversionName, Entity<TableDefinition>>[]>;
|
|
3027
268
|
getMediaUrls(collectionName?: TCollectionName, conversionName?: TConversionName): Promise<string[]>;
|
|
3028
269
|
getMediaPaths(collectionName?: TCollectionName, conversionName?: TConversionName): Promise<string[]>;
|
|
3029
|
-
getFirstMedia(collectionName?: TCollectionName): Promise<MediaItem<TCollectionName, TConversionName, Entity
|
|
270
|
+
getFirstMedia(collectionName?: TCollectionName): Promise<MediaItem<TCollectionName, TConversionName, Entity<TableDefinition>> | null>;
|
|
3030
271
|
getFirstMediaUrl(collectionName?: TCollectionName, conversionName?: TConversionName): Promise<string | null>;
|
|
3031
272
|
getFirstMediaPath(collectionName?: TCollectionName, conversionName?: TConversionName): Promise<string | null>;
|
|
3032
273
|
getFirstTemporaryUrl(collectionName?: TCollectionName, conversionName?: TConversionName, options?: {
|
|
@@ -3037,7 +278,7 @@ type MediaEnabledEntityMethods<TCollectionName extends string, TConversionName e
|
|
|
3037
278
|
clearMediaCollection(collectionName?: TCollectionName): Promise<void>;
|
|
3038
279
|
regenerateMedia(collectionName?: TCollectionName, conversions?: TConversionName | readonly TConversionName[]): Promise<void>;
|
|
3039
280
|
};
|
|
3040
|
-
type MediaEnabledEntityResult<TEntity, TCollectionName extends string, TConversionName extends string> = TEntity extends EntityWithLoaded
|
|
281
|
+
type MediaEnabledEntityResult<TEntity, TCollectionName extends string, TConversionName extends string> = TEntity extends EntityWithLoaded<infer _TTable extends TableDefinition, infer _TRelations extends RelationMap, infer _TLoaded> ? unknown extends _TLoaded ? MediaEnabledEntity<_TTable, TCollectionName, TConversionName, _TRelations> : TEntity & MediaEnabledEntityMethods<TCollectionName, TConversionName> : TEntity extends Entity<infer _TTable extends TableDefinition, infer _TRelations extends RelationMap> ? TEntity & MediaEnabledEntityMethods<TCollectionName, TConversionName> : TEntity;
|
|
3041
282
|
type MediaEnabledFunction<TFunction, TCollectionName extends string, TConversionName extends string> = TFunction extends {
|
|
3042
283
|
(...args: infer TArgs1): infer TReturn1;
|
|
3043
284
|
(...args: infer TArgs2): infer TReturn2;
|
|
@@ -3063,39 +304,46 @@ type MediaEnabledFunction<TFunction, TCollectionName extends string, TConversion
|
|
|
3063
304
|
(...args: TArgs1): MediaEnabledResult<TReturn1, TCollectionName, TConversionName>;
|
|
3064
305
|
(...args: TArgs2): MediaEnabledResult<TReturn2, TCollectionName, TConversionName>;
|
|
3065
306
|
} : TFunction extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => MediaEnabledResult<TReturn, TCollectionName, TConversionName> : TFunction;
|
|
3066
|
-
type MediaEnabledQueryBuilder<TBuilder, TCollectionName extends string, TConversionName extends string> =
|
|
3067
|
-
[K in keyof TBuilder]: MediaEnabledFunction<TBuilder[K], TCollectionName, TConversionName>;
|
|
307
|
+
type MediaEnabledQueryBuilder<TBuilder, TCollectionName extends string, TConversionName extends string> = {
|
|
308
|
+
[K in keyof TBuilder]: K extends 'with' ? MediaEnabledQueryBuilderWith<TBuilder, TCollectionName, TConversionName> : K extends 'withCount' | 'withExists' ? MediaEnabledRelationAggregate<TBuilder, TCollectionName, TConversionName> : K extends 'withSum' | 'withAvg' | 'withMin' | 'withMax' ? MediaEnabledRelationColumnAggregate<TBuilder, TCollectionName, TConversionName> : MediaEnabledFunction<TBuilder[K], TCollectionName, TConversionName>;
|
|
3068
309
|
};
|
|
3069
310
|
type MediaEnabledPaginatedResult<TResult, TPaginator, TCollectionName extends string, TConversionName extends string> = Omit<TResult, keyof TPaginator> & TPaginator & (TResult extends {
|
|
3070
311
|
readonly data: infer TData;
|
|
3071
312
|
} ? {
|
|
3072
313
|
readonly data: MediaEnabledResult<TData, TCollectionName, TConversionName>;
|
|
3073
314
|
} : Record<never, never>);
|
|
3074
|
-
type MediaEnabledResult<TValue, TCollectionName extends string, TConversionName extends string> = TValue extends Promise<infer TResult> ? Promise<MediaEnabledResult<TResult, TCollectionName, TConversionName>> : TValue extends AsyncGenerator<infer TYield, infer TReturn, infer TNext> ? AsyncGenerator<MediaEnabledResult<TYield, TCollectionName, TConversionName>, TReturn, TNext> : TValue extends ModelQueryBuilder
|
|
315
|
+
type MediaEnabledResult<TValue, TCollectionName extends string, TConversionName extends string> = TValue extends Promise<infer TResult> ? Promise<MediaEnabledResult<TResult, TCollectionName, TConversionName>> : TValue extends AsyncGenerator<infer TYield, infer TReturn, infer TNext> ? AsyncGenerator<MediaEnabledResult<TYield, TCollectionName, TConversionName>, TReturn, TNext> : TValue extends ModelQueryBuilder<infer TTable extends TableDefinition, infer TRelations extends RelationMap, infer TLoaded> ? MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded>, TCollectionName, TConversionName> : TValue extends ModelCollection<infer TTable extends TableDefinition, infer TRelations extends RelationMap, infer TItem> ? TItem extends Entity<TTable, TRelations> ? ModelCollection<TTable, TRelations, MediaEnabledEntityResult<TItem, TCollectionName, TConversionName>> : TValue : TValue extends PaginatedResult<infer TItem> ? MediaEnabledPaginatedResult<TValue, PaginatedResult<MediaEnabledResult<TItem, TCollectionName, TConversionName>>, TCollectionName, TConversionName> : TValue extends SimplePaginatedResult<infer TItem> ? MediaEnabledPaginatedResult<TValue, SimplePaginatedResult<MediaEnabledResult<TItem, TCollectionName, TConversionName>>, TCollectionName, TConversionName> : TValue extends CursorPaginatedResult<infer TItem> ? MediaEnabledPaginatedResult<TValue, CursorPaginatedResult<MediaEnabledResult<TItem, TCollectionName, TConversionName>>, TCollectionName, TConversionName> : MediaEnabledEntityResult<TValue, TCollectionName, TConversionName>;
|
|
3075
316
|
type MediaModelStatic = {
|
|
3076
317
|
readonly definition: {
|
|
3077
318
|
readonly name: string;
|
|
3078
|
-
readonly table: TableDefinition
|
|
319
|
+
readonly table: TableDefinition;
|
|
3079
320
|
};
|
|
3080
321
|
readonly resolveRelationUsing: (name: string, resolver: DynamicRelationResolver) => unknown;
|
|
3081
322
|
};
|
|
3082
|
-
type MediaRelationPath<TRelations extends RelationMap
|
|
3083
|
-
type MediaRelationConstraint<TTable extends TableDefinition
|
|
3084
|
-
type
|
|
3085
|
-
type
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
}
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
323
|
+
type MediaRelationPath<TRelations extends RelationMap> = ModelRelationPath<TRelations>;
|
|
324
|
+
type MediaRelationConstraint<TTable extends TableDefinition, TRelations extends RelationMap> = RelationConstraintDefinition & ((query: ModelQueryBuilder<TTable, TRelations>) => unknown);
|
|
325
|
+
type MediaRelationConstraintMap<TRelations extends RelationMap> = Readonly<Partial<Record<MediaRelationPath<TRelations>, MediaRelationConstraint<TableDefinition, TRelations>>>>;
|
|
326
|
+
type MediaEnabledQueryBuilderWith<TBuilder, TCollectionName extends string, TConversionName extends string> = TBuilder extends ModelQueryBuilder<infer TTable extends TableDefinition, infer TRelations extends RelationMap, infer TLoaded> ? {
|
|
327
|
+
<TPaths extends readonly MediaRelationPath<TRelations>[]>(...relations: TPaths): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, TPaths>>, TCollectionName, TConversionName>;
|
|
328
|
+
<TPath extends MediaRelationPath<TRelations>>(relation: TPath, constraint: MediaRelationConstraint<TTable, TRelations>): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, readonly [TPath]>>, TCollectionName, TConversionName>;
|
|
329
|
+
(relations: MediaRelationConstraintMap<TRelations>): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded>, TCollectionName, TConversionName>;
|
|
330
|
+
<TPaths extends readonly MediaRelationPath<TRelations>[]>(relations: TPaths): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded & ResolveEagerLoads<TRelations, TPaths>>, TCollectionName, TConversionName>;
|
|
331
|
+
} : TBuilder extends {
|
|
332
|
+
with: infer TWith;
|
|
333
|
+
} ? MediaEnabledFunction<TWith, TCollectionName, TConversionName> : never;
|
|
334
|
+
type MediaEnabledRelationAggregate<TBuilder, TCollectionName extends string, TConversionName extends string> = TBuilder extends ModelQueryBuilder<infer TTable extends TableDefinition, infer TRelations extends RelationMap, infer TLoaded> ? {
|
|
335
|
+
(...relations: readonly MediaRelationPath<TRelations>[]): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded>, TCollectionName, TConversionName>;
|
|
336
|
+
(relations: MediaRelationConstraintMap<TRelations>): MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded>, TCollectionName, TConversionName>;
|
|
337
|
+
} : never;
|
|
338
|
+
type MediaEnabledRelationColumnAggregate<TBuilder, TCollectionName extends string, TConversionName extends string> = TBuilder extends ModelQueryBuilder<infer TTable extends TableDefinition, infer TRelations extends RelationMap, infer TLoaded> ? <TPath extends MediaRelationPath<TRelations>>(first: TPath | MediaRelationConstraintMap<TRelations>, column: RelatedColumnNameForRelationPath<TRelations, TPath>, ...rest: readonly MediaRelationPath<TRelations>[]) => MediaEnabledQueryBuilder<ModelQueryBuilder<TTable, TRelations, TLoaded>, TCollectionName, TConversionName> : never;
|
|
339
|
+
type MediaEnabledStaticWith<TModel extends MediaModelStatic, TCollectionName extends string, TConversionName extends string> = TModel extends {
|
|
340
|
+
query(): infer TBuilder;
|
|
341
|
+
} ? MediaEnabledQueryBuilderWith<TBuilder, TCollectionName, TConversionName> : TModel extends {
|
|
3096
342
|
with: infer TWith;
|
|
3097
343
|
} ? MediaEnabledFunction<TWith, TCollectionName, TConversionName> : never;
|
|
3098
|
-
type MediaEnabledModel<TModel extends MediaModelStatic, TDefinition extends MediaDefinitionInput> =
|
|
344
|
+
type MediaEnabledModel<TModel extends MediaModelStatic, TDefinition extends MediaDefinitionInput> = {
|
|
345
|
+
[K in keyof TModel]: K extends 'with' ? MediaEnabledStaticWith<TModel, MediaCollectionName<TDefinition>, MediaConversionName<TDefinition>> : MediaEnabledFunction<TModel[K], MediaCollectionName<TDefinition>, MediaConversionName<TDefinition>>;
|
|
346
|
+
} & TModel;
|
|
3099
347
|
declare function defineMediaModel<TModel extends MediaModelStatic, const TDefinition extends MediaDefinitionInput>(model: TModel, definition: TDefinition | MediaDefinitionFactory<TDefinition>): MediaEnabledModel<TModel, TDefinition>;
|
|
3100
348
|
|
|
3101
349
|
declare const MEDIA_GENERATE_CONVERSIONS_JOB = "media.generate-conversions";
|