@h3ravel/arquebus 0.2.5 → 0.2.6
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/bin/index.cjs +1 -1
- package/bin/index.js +1 -1
- package/dist/migrations/index.cjs +1 -0
- package/dist/migrations/index.d.cts +1281 -0
- package/dist/migrations/index.d.ts +1281 -0
- package/dist/migrations/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1281 @@
|
|
|
1
|
+
import { Collection as Collection$2 } from 'collect.js';
|
|
2
|
+
import Knex, { Knex as Knex$1 } from 'knex';
|
|
3
|
+
|
|
4
|
+
declare class Collection$1<I extends Model$1 | Model> extends Collection$2<I> implements ICollection<I> {
|
|
5
|
+
private newConstructor;
|
|
6
|
+
getConstructor<T extends typeof Collection$1<I>>(this: InstanceType<T>): T;
|
|
7
|
+
load(...relations: I[]): Promise<Collection$1<I>>;
|
|
8
|
+
loadAggregate<I>(relations: I, column: string, action?: string | null | TFunction): Promise<this>;
|
|
9
|
+
loadCount(relations: I): Promise<this>;
|
|
10
|
+
loadMax(relation: I, column: string): Promise<this>;
|
|
11
|
+
loadMin(relation: I, column: string): Promise<this>;
|
|
12
|
+
loadSum(relation: I, column: string): Promise<this>;
|
|
13
|
+
loadAvg(relation: I, column: string): Promise<this>;
|
|
14
|
+
mapThen(callback: () => void): Promise<void[]>;
|
|
15
|
+
modelKeys(): any[];
|
|
16
|
+
contains<K, V>(key: keyof I | K | TFunction, value?: V): boolean;
|
|
17
|
+
diff(items: ICollection<any> | any[]): any;
|
|
18
|
+
except(keys: any[]): any;
|
|
19
|
+
intersect(items: I[]): any;
|
|
20
|
+
unique(key?: TFunction | keyof I, _strict?: boolean): any;
|
|
21
|
+
find(key: any, defaultValue?: null): any;
|
|
22
|
+
fresh(...args: any[]): Promise<any>;
|
|
23
|
+
makeVisible(attributes: any): this;
|
|
24
|
+
makeHidden(attributes: any): this;
|
|
25
|
+
append(attributes: any): this;
|
|
26
|
+
only(keys: any[]): any;
|
|
27
|
+
getDictionary(items?: ICollection<any> | any[]): TGeneric;
|
|
28
|
+
toQuery(): any;
|
|
29
|
+
toData(): (I | {
|
|
30
|
+
[x: string]: any;
|
|
31
|
+
[x: number]: any;
|
|
32
|
+
[x: symbol]: any;
|
|
33
|
+
})[];
|
|
34
|
+
toJSON(): (I | {
|
|
35
|
+
[x: string]: any;
|
|
36
|
+
[x: number]: any;
|
|
37
|
+
[x: symbol]: any;
|
|
38
|
+
})[];
|
|
39
|
+
toJson(...args: any[]): string;
|
|
40
|
+
[Symbol.iterator]: () => Iterator<I>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare class Paginator<T extends Model$1, K extends IPaginatorParams = IPaginatorParams> implements IPaginator<T, K> {
|
|
44
|
+
static formatter: (paginator: IPaginator<any>) => any | null;
|
|
45
|
+
_items: Collection$1<T>;
|
|
46
|
+
_total: number;
|
|
47
|
+
_perPage: number;
|
|
48
|
+
_lastPage: number;
|
|
49
|
+
_currentPage: number;
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
options: TGeneric;
|
|
52
|
+
static setFormatter(formatter: (paginator: IPaginator<any>) => any | null): void;
|
|
53
|
+
constructor(items: T[], total: number, perPage: number, currentPage?: number, options?: TGeneric);
|
|
54
|
+
setItems(items: T[]): void;
|
|
55
|
+
firstItem(): number | null;
|
|
56
|
+
lastItem(): number | null;
|
|
57
|
+
hasMorePages(): boolean;
|
|
58
|
+
get(index: number): T | null;
|
|
59
|
+
count(): number;
|
|
60
|
+
items(): Collection$1<T>;
|
|
61
|
+
map(callback: (value: T, index: number) => T): Collection$1<T>;
|
|
62
|
+
currentPage(): number;
|
|
63
|
+
onFirstPage(): boolean;
|
|
64
|
+
perPage(): number;
|
|
65
|
+
lastPage(): number;
|
|
66
|
+
total(): number;
|
|
67
|
+
toData(): any;
|
|
68
|
+
toJSON(): any;
|
|
69
|
+
toJson(...args: any[]): string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare class Scope<M extends Model$1 = Model$1> implements IScope {
|
|
73
|
+
constructor();
|
|
74
|
+
apply(_builder: Builder<M>, _model: M): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare const Inference$2: {
|
|
78
|
+
new <M extends Model$1 = Model$1, R = IModel | ICollection<M>>(): IBuilder<M, R>;
|
|
79
|
+
};
|
|
80
|
+
declare class Builder<M extends Model$1 = Model$1, R = IModel | ICollection<M>> extends Inference$2 {
|
|
81
|
+
query: IBuilder<M, R>;
|
|
82
|
+
connection: any;
|
|
83
|
+
model: M;
|
|
84
|
+
actions: any[];
|
|
85
|
+
localMacros: TGeneric<(...args: any[]) => any, keyof Omit<IBuilder<M, R>, number>>;
|
|
86
|
+
eagerLoad: TGeneric<(...args: any[]) => any>;
|
|
87
|
+
globalScopes: TGeneric<Scope<M> | ((arg: Builder<M, R>) => Builder<M, R>)>;
|
|
88
|
+
onDeleteCallback?: (builder: Builder<M, R>) => Promise<boolean | number>;
|
|
89
|
+
constructor(query: IBuilder<M, R>);
|
|
90
|
+
asProxy(): Builder<M, R>;
|
|
91
|
+
orWhere(...args: any[]): this;
|
|
92
|
+
chunk<C extends TFunction>(count: number, callback: C): Promise<boolean>;
|
|
93
|
+
enforceOrderBy(this: any): void;
|
|
94
|
+
clone(this: any): any;
|
|
95
|
+
forPage(this: any, page: number, perPage?: number): any;
|
|
96
|
+
insert(...args: Parameters<typeof this$1.query.insert>): Promise<any>;
|
|
97
|
+
update<T extends TGeneric>(values: T): Promise<any>;
|
|
98
|
+
increment(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
99
|
+
decrement(column: string, amount?: number, extra?: {}): Promise<any>;
|
|
100
|
+
addUpdatedAtColumn(values: TGeneric<string>): TGeneric<string>;
|
|
101
|
+
delete(): Promise<number | boolean>;
|
|
102
|
+
onDelete<C extends TFunction<any, Promise<number | boolean>>>(callback: C): void;
|
|
103
|
+
forceDelete(): Promise<number | boolean>;
|
|
104
|
+
create(attributes?: {}): Promise<any>;
|
|
105
|
+
newModelInstance(attributes?: {}): any;
|
|
106
|
+
getQuery(): IBuilder<M, R>;
|
|
107
|
+
getModel(): M;
|
|
108
|
+
setModel<MO extends Model$1>(model: MO): this;
|
|
109
|
+
qualifyColumn(column: string): string;
|
|
110
|
+
setTable(table: string): this;
|
|
111
|
+
applyScopes(): this;
|
|
112
|
+
hasNamedScope(name: string): boolean;
|
|
113
|
+
callNamedScope(scope: string, parameters: any[]): any;
|
|
114
|
+
callScope(scope: (builder: this, ...args: any[]) => this, parameters?: never[]): this;
|
|
115
|
+
scopes(scopes: string[]): this;
|
|
116
|
+
withGlobalScope(identifier: string, scope: any): this;
|
|
117
|
+
withoutGlobalScope(scope: Scope | string): this;
|
|
118
|
+
macro<N extends string>(name: N, callback: (builder: TGeneric & IBuilder<M>, attrs: any, vals: any) => any): this;
|
|
119
|
+
hasMacro(name: string): boolean;
|
|
120
|
+
getMacro(name: string): (...args: any[]) => any;
|
|
121
|
+
with(...args: any[]): this;
|
|
122
|
+
has(relation: any, operator?: string, count?: number, boolean?: string, callback?: TFunction | null): any;
|
|
123
|
+
orHas(relation: any, operator?: string, count?: number): any;
|
|
124
|
+
doesntHave(relation: any, boolean?: string, callback?: TFunction | null): any;
|
|
125
|
+
orDoesntHave(relation: any): any;
|
|
126
|
+
whereHas(relation: any, callback?: TFunction | null, operator?: string, count?: number): any;
|
|
127
|
+
orWhereHas(relation: any, callback?: TFunction | null, operator?: string, count?: number): any;
|
|
128
|
+
whereRelation(relation: any, ...args: any[]): any;
|
|
129
|
+
orWhereRelation(relation: any, ...args: any[]): any;
|
|
130
|
+
hasNested(relations: any, operator?: string, count?: number, boolean?: string, callback?: TFunction | null): any;
|
|
131
|
+
canUseExistsForExistenceCheck(operator: string, count: number): boolean;
|
|
132
|
+
addHasWhere(hasQuery: any, relation: any, operator: string, count: number, boolean: string): any;
|
|
133
|
+
addWhereExistsQuery(this: any, query: any, boolean?: string, not?: boolean): any;
|
|
134
|
+
addWhereCountQuery(this: any, query: any, operator?: string, count?: number, boolean?: string): any;
|
|
135
|
+
withAggregate(relations: any, column: string, action?: string | null): this;
|
|
136
|
+
toSql(): any;
|
|
137
|
+
mergeConstraintsFrom(_from: any): this;
|
|
138
|
+
selectSub(query: Builder<M>, as: string): any;
|
|
139
|
+
createSub(query: any): any[];
|
|
140
|
+
parseSub(query: any): any[];
|
|
141
|
+
prependDatabaseNameIfCrossDatabaseQuery(query: any): any;
|
|
142
|
+
getRelationWithoutConstraints(relation: string): any;
|
|
143
|
+
withCount(...args: any[]): this;
|
|
144
|
+
withMax(relation: any, column: string): this;
|
|
145
|
+
withMin(relation: any, column: string): this;
|
|
146
|
+
withAvg(relation: any, column: string): this;
|
|
147
|
+
withSum(relation: any, column: string): this;
|
|
148
|
+
withExists(relation: any): this;
|
|
149
|
+
parseWithRelations(relations: TGeneric): TGeneric | never[];
|
|
150
|
+
addNestedWiths(name: string, results: TGeneric): TGeneric;
|
|
151
|
+
prepareNestedWithRelationships(relations: TGeneric, prefix?: string): TGeneric;
|
|
152
|
+
combineConstraints(constraints: TFunction[]): (builder: Builder<M>) => Builder<M, IModel | ICollection<M>>;
|
|
153
|
+
parseNameAndAttributeSelectionConstraint(name: string, value: string): (string | ((query: any) => void))[];
|
|
154
|
+
createSelectWithConstraint(name: string): (string | ((query: any) => void))[];
|
|
155
|
+
related(relation: string): any;
|
|
156
|
+
take(this: any, ...args: any[]): any;
|
|
157
|
+
skip(this: any, ...args: any[]): any;
|
|
158
|
+
first(this: any, ...columns: any[]): Promise<M | null>;
|
|
159
|
+
firstOrFail(...columns: any[]): Promise<M>;
|
|
160
|
+
findOrFail(this: any, ...args: any[]): Promise<M>;
|
|
161
|
+
findOrNew(id: string, columns?: string[]): Promise<any>;
|
|
162
|
+
firstOrNew(this: any, attributes?: {}, values?: {}): Promise<any>;
|
|
163
|
+
firstOrCreate(this: any, attributes?: TGeneric, values?: {}): Promise<any>;
|
|
164
|
+
updateOrCreate(attributes: TGeneric, values?: {}): Promise<any>;
|
|
165
|
+
latest(column?: string): this;
|
|
166
|
+
oldest(column?: string): this;
|
|
167
|
+
find(this: any, id: string | number | Collection$1<M>, columns?: string[]): Promise<any>;
|
|
168
|
+
findMany(this: any, ids: string[] | number[] | ICollection<any>, columns?: string[]): Promise<any>;
|
|
169
|
+
pluck(column: string): Promise<any>;
|
|
170
|
+
destroy(this: any, ids?: (string | number)[] | TFunction | Collection$1<M>): Promise<number>;
|
|
171
|
+
get<M extends Model$1>(columns?: string | string[]): Promise<Collection$1<M>>;
|
|
172
|
+
all(columns?: string[]): Promise<any>;
|
|
173
|
+
paginate(this: any, page?: number, perPage?: number): Promise<Paginator<any, IPaginatorParams>>;
|
|
174
|
+
getModels(...columns: any[]): Promise<any[]>;
|
|
175
|
+
getRelation(name: string): any;
|
|
176
|
+
relationsNestedUnder(relation: string): TGeneric;
|
|
177
|
+
isNestedUnder(relation: string, name: string): boolean;
|
|
178
|
+
eagerLoadRelation<M extends Model$1>(models: M[], name: string, constraints: any): Promise<any>;
|
|
179
|
+
eagerLoadRelations<M extends Model$1>(models: M[]): Promise<M[]>;
|
|
180
|
+
hydrate(items: any[]): Collection$1<any>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare class Relation$1 {
|
|
184
|
+
query: QueryBuilder;
|
|
185
|
+
parent: any;
|
|
186
|
+
related: any;
|
|
187
|
+
eagerKeysWereEmpty: boolean;
|
|
188
|
+
static constraints: boolean;
|
|
189
|
+
static selfJoinCount: number;
|
|
190
|
+
constructor(query: any, parent: any);
|
|
191
|
+
static extend(trait: Record<string, any>): void;
|
|
192
|
+
static noConstraints(callback: () => any): any;
|
|
193
|
+
asProxy(): any;
|
|
194
|
+
getRelated(): any;
|
|
195
|
+
getKeys(models: any[], key?: string | null): any[];
|
|
196
|
+
getRelationQuery(): any;
|
|
197
|
+
whereInEager(whereIn: string, key: string, modelKeys: any[], query?: any): void;
|
|
198
|
+
whereInMethod(model: any, key: string): string;
|
|
199
|
+
getEager(): any;
|
|
200
|
+
get(columns?: string | string[]): Promise<any>;
|
|
201
|
+
first(columns?: string[]): Promise<any>;
|
|
202
|
+
paginate(...args: any[]): Promise<any>;
|
|
203
|
+
count(...args: any[]): Promise<any>;
|
|
204
|
+
toSql(): string;
|
|
205
|
+
addConstraints(): void;
|
|
206
|
+
getRelationCountHash(incrementJoinCount?: boolean): string;
|
|
207
|
+
getRelationExistenceQuery(query: any, parentQuery: any, columns?: string[]): any;
|
|
208
|
+
getRelationExistenceCountQuery(query: any, parentQuery: any): any;
|
|
209
|
+
getQualifiedParentKeyName(): string;
|
|
210
|
+
getExistenceCompareKey(this: any): string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class arquebus<M extends Model$1 = Model$1> {
|
|
214
|
+
static connectorFactory: typeof Knex | null;
|
|
215
|
+
static instance: arquebus | null;
|
|
216
|
+
manager: Record<string, QueryBuilder<M>>;
|
|
217
|
+
connections: Record<string, TConfig>;
|
|
218
|
+
models: Record<string, typeof Model$1>;
|
|
219
|
+
constructor();
|
|
220
|
+
getConstructor<T extends typeof arquebus>(this: InstanceType<T>): T;
|
|
221
|
+
static getInstance(): arquebus<Model$1>;
|
|
222
|
+
/**
|
|
223
|
+
* Initialize a database connection
|
|
224
|
+
*
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
static connection<C extends TBaseConfig['client']>(connection?: C | null): QueryBuilder<Model$1>;
|
|
228
|
+
static setConnectorFactory(connectorFactory: typeof Knex): void;
|
|
229
|
+
static getConnectorFactory(): typeof Knex;
|
|
230
|
+
static addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
231
|
+
static beginTransaction(connection?: null): Promise<Knex.Knex.Transaction<any, any[]> | undefined>;
|
|
232
|
+
static transaction(callback: TFunction, connection?: null): Promise<Knex.Knex.Transaction<any, any[]>> | undefined;
|
|
233
|
+
static table(name: string, connection?: null): IQueryBuilder<Model$1, Model$1 | Model$1[]>;
|
|
234
|
+
static schema(connection?: null): SchemaBuilder;
|
|
235
|
+
static destroyAll(): Promise<void>;
|
|
236
|
+
static createModel<X extends TGeneric>(name: string, options: X): typeof Model$1;
|
|
237
|
+
connection(connection?: string | null): QueryBuilder<M, M | M[]>;
|
|
238
|
+
getConnection(name?: string | null): QueryBuilder<M, M | M[]>;
|
|
239
|
+
addConnection(config: TConfig | TBaseConfig, name?: string): void;
|
|
240
|
+
/**
|
|
241
|
+
* Autoload the config file
|
|
242
|
+
*
|
|
243
|
+
* @param addConnection
|
|
244
|
+
* @default true
|
|
245
|
+
* If set to `false` we will no attempt add the connection, we
|
|
246
|
+
* will just go ahead and return the config
|
|
247
|
+
*
|
|
248
|
+
* @returns
|
|
249
|
+
*/
|
|
250
|
+
static autoLoad(addConnection?: boolean): Promise<TBaseConfig>;
|
|
251
|
+
beginTransaction(connection?: null): Promise<Knex.Knex.Transaction<any, any[]> | undefined>;
|
|
252
|
+
transaction(callback: TFunction, connection?: null): Promise<Knex.Knex.Transaction<any, any[]>> | undefined;
|
|
253
|
+
table(name: string, connection?: null): IQueryBuilder<M, M | M[]>;
|
|
254
|
+
schema(connection?: null): SchemaBuilder;
|
|
255
|
+
destroyAll(): Promise<void>;
|
|
256
|
+
createModel(name: string, options?: ModelOptions): typeof Model$1;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
declare class MigrationRepository {
|
|
260
|
+
resolver: typeof arquebus;
|
|
261
|
+
table: string;
|
|
262
|
+
connection: TBaseConfig['client'] | null;
|
|
263
|
+
constructor(resolver: typeof arquebus, table: string);
|
|
264
|
+
getRan(): Promise<ICollection<any>>;
|
|
265
|
+
getMigrations(steps: number): Promise<any>;
|
|
266
|
+
getMigrationsByBatch(batch: number): Promise<any>;
|
|
267
|
+
getLast(): Promise<any>;
|
|
268
|
+
getMigrationBatches(): Promise<TGeneric>;
|
|
269
|
+
log(file: string, batch: number): Promise<void>;
|
|
270
|
+
delete(migration: TGeneric): Promise<void>;
|
|
271
|
+
getNextBatchNumber(): Promise<number>;
|
|
272
|
+
getLastBatchNumber(): Promise<number>;
|
|
273
|
+
createRepository(): Promise<void>;
|
|
274
|
+
repositoryExists(): Promise<boolean>;
|
|
275
|
+
deleteRepository(): Promise<void>;
|
|
276
|
+
getTable(): IQueryBuilder<Model$1, Model$1 | Model$1[]>;
|
|
277
|
+
getConnection(): QueryBuilder<Model$1, Model$1 | Model$1[]>;
|
|
278
|
+
setSource(name: TBaseConfig['client']): void;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare namespace migrationRepository {
|
|
282
|
+
export { MigrationRepository as default };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface MigrationOptions {
|
|
286
|
+
pretend?: boolean;
|
|
287
|
+
step?: number;
|
|
288
|
+
batch?: number;
|
|
289
|
+
}
|
|
290
|
+
declare class Migrator {
|
|
291
|
+
events: any;
|
|
292
|
+
repository: MigrationRepository;
|
|
293
|
+
files: any;
|
|
294
|
+
resolver: typeof arquebus;
|
|
295
|
+
connection: TBaseConfig['client'];
|
|
296
|
+
paths: string[];
|
|
297
|
+
output: boolean | null;
|
|
298
|
+
constructor(repository: MigrationRepository, resolver?: typeof arquebus | null, files?: any, dispatcher?: any);
|
|
299
|
+
run(paths?: string[], options?: MigrationOptions): Promise<string[]>;
|
|
300
|
+
pendingMigrations(files: Record<string, string>, ran: string[]): string[];
|
|
301
|
+
runPending(migrations: string[], options?: MigrationOptions): Promise<void>;
|
|
302
|
+
runUp(file: string, batch: number, _pretend: boolean): Promise<void>;
|
|
303
|
+
runDown(file: string, migration: {
|
|
304
|
+
migration: string;
|
|
305
|
+
}, _pretend: boolean): Promise<void>;
|
|
306
|
+
rollback(paths?: string[], options?: MigrationOptions): Promise<string[]>;
|
|
307
|
+
getMigrationsForRollback(options: MigrationOptions): Promise<{
|
|
308
|
+
migration: string;
|
|
309
|
+
}[]>;
|
|
310
|
+
rollbackMigrations(migrations: {
|
|
311
|
+
migration: string;
|
|
312
|
+
}[], paths: string[], options: MigrationOptions): Promise<string[]>;
|
|
313
|
+
reset(_paths?: string[], _pretend?: boolean): Promise<string[]> | string[];
|
|
314
|
+
resetMigrations(migrations: {
|
|
315
|
+
migration: string;
|
|
316
|
+
}[], paths: string[], pretend?: boolean): Promise<string[]>;
|
|
317
|
+
runMigration(migration: IMigration, method: 'up' | 'down'): Promise<void>;
|
|
318
|
+
runMethod(connection: QueryBuilder, migration: IMigration, method: 'up' | 'down'): Promise<void>;
|
|
319
|
+
resolvePath(filePath: string): Promise<IMigration>;
|
|
320
|
+
getMigrationClass(migrationName: string): string;
|
|
321
|
+
getMigrationFiles(paths: string[]): Promise<Record<string, string>>;
|
|
322
|
+
getMigrationName(filePath: string): string;
|
|
323
|
+
path(p: string): void;
|
|
324
|
+
getPaths(): string[];
|
|
325
|
+
getConnection(): TBaseConfig['client'];
|
|
326
|
+
resolveConnection(connection?: TBaseConfig['client']): any;
|
|
327
|
+
getRepository(): MigrationRepository;
|
|
328
|
+
repositoryExists(): Promise<boolean>;
|
|
329
|
+
hasRunAnyMigrations(): Promise<boolean>;
|
|
330
|
+
deleteRepository(): void;
|
|
331
|
+
setOutput(output: boolean): this;
|
|
332
|
+
write(...args: any[]): void;
|
|
333
|
+
writeTwoColumns(name: string, ...args: string[]): void;
|
|
334
|
+
writeTask(description: string, task: () => Promise<any> | any): Promise<void>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
type migrator_MigrationOptions = MigrationOptions;
|
|
338
|
+
declare namespace migrator {
|
|
339
|
+
export { type migrator_MigrationOptions as MigrationOptions, Migrator as default };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface TBaseConfig {
|
|
343
|
+
client: 'mysql' | 'mysql2' | 'sqlite3' | 'oracle' | 'mariadb' | 'pg';
|
|
344
|
+
connection: {
|
|
345
|
+
typeCast?(field: TField, next: TFunction): any;
|
|
346
|
+
dateStrings?: boolean;
|
|
347
|
+
};
|
|
348
|
+
pool?: {
|
|
349
|
+
afterCreate: (connection: TConfig, callback: (val: any, con: any) => void) => Promise<any>;
|
|
350
|
+
} | undefined;
|
|
351
|
+
connections?: arquebus['connections'];
|
|
352
|
+
migrations?: {
|
|
353
|
+
table: string;
|
|
354
|
+
path: string;
|
|
355
|
+
};
|
|
356
|
+
factories?: {
|
|
357
|
+
path: string;
|
|
358
|
+
};
|
|
359
|
+
seeders?: {
|
|
360
|
+
path: string;
|
|
361
|
+
};
|
|
362
|
+
models?: {
|
|
363
|
+
path: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
type TConfig = TBaseConfig & ({
|
|
367
|
+
client: 'pg';
|
|
368
|
+
connection: Knex$1.PgConnectionConfig;
|
|
369
|
+
} | {
|
|
370
|
+
client: 'oracle';
|
|
371
|
+
connection: Knex$1.OracleDbConnectionConfig;
|
|
372
|
+
} | {
|
|
373
|
+
client: 'mysql2';
|
|
374
|
+
connection: Knex$1.MySql2ConnectionConfig;
|
|
375
|
+
} | {
|
|
376
|
+
client: 'mysql';
|
|
377
|
+
connection: Knex$1.MySqlConnectionConfig;
|
|
378
|
+
} | {
|
|
379
|
+
client: 'sqlite3';
|
|
380
|
+
connection: Knex$1.Sqlite3ConnectionConfig;
|
|
381
|
+
useNullAsDefault?: boolean;
|
|
382
|
+
} | {
|
|
383
|
+
client: 'mariadb';
|
|
384
|
+
connection: Knex$1.MariaSqlConnectionConfig;
|
|
385
|
+
useNullAsDefault?: boolean;
|
|
386
|
+
});
|
|
387
|
+
interface ModelOptions<M extends Model$1 = Model$1> {
|
|
388
|
+
table?: string;
|
|
389
|
+
scopes?: TGeneric<(...args: any[]) => Builder<M>>;
|
|
390
|
+
plugins?: (<X extends MixinConstructor<M>>(Model: X) => MixinConstructor<M>)[];
|
|
391
|
+
relations?: TGeneric<(...args: any[]) => Relation$1>;
|
|
392
|
+
attributes?: TGeneric<Attribute>;
|
|
393
|
+
CREATED_AT?: string;
|
|
394
|
+
UPDATED_AT?: string;
|
|
395
|
+
DELETED_AT?: string;
|
|
396
|
+
connection?: TBaseConfig['client'];
|
|
397
|
+
timestamps?: boolean;
|
|
398
|
+
primaryKey?: string;
|
|
399
|
+
incrementing?: boolean;
|
|
400
|
+
keyType?: 'int' | 'string';
|
|
401
|
+
with?: Model$1['with'];
|
|
402
|
+
casts?: Model$1['casts'];
|
|
403
|
+
}
|
|
404
|
+
interface TField {
|
|
405
|
+
type: 'VAR_STRING' | 'BLOB' | 'DATETIME' | 'TIMESTAMP' | 'LONG' | 'JSON';
|
|
406
|
+
length: number;
|
|
407
|
+
db: string;
|
|
408
|
+
table: string;
|
|
409
|
+
name: string;
|
|
410
|
+
string: TFunction;
|
|
411
|
+
buffer: TFunction;
|
|
412
|
+
geometry: TFunction;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
interface Attribute {
|
|
416
|
+
make(config: {
|
|
417
|
+
get?: TFunction | null;
|
|
418
|
+
set?: TFunction | null;
|
|
419
|
+
}): Attribute;
|
|
420
|
+
get: TFunction | null;
|
|
421
|
+
set: TFunction | null;
|
|
422
|
+
withCaching?: boolean;
|
|
423
|
+
withObjectCaching?: boolean;
|
|
424
|
+
}
|
|
425
|
+
type Relation<M extends Model$1> = IBuilder<M, any> & {};
|
|
426
|
+
interface HasOneOrMany<M extends Model$1> extends Relation<M> {
|
|
427
|
+
save(model: M): Promise<M>;
|
|
428
|
+
saveMany(models: M[] | ICollection<M>): Promise<ICollection<M>>;
|
|
429
|
+
create(attributes?: any): Promise<M>;
|
|
430
|
+
createMany(records: any[]): Promise<ICollection<M>>;
|
|
431
|
+
}
|
|
432
|
+
interface HasOne<M extends Model$1> extends HasOneOrMany<M> {
|
|
433
|
+
getResults(): Promise<M | null>;
|
|
434
|
+
withDefault(callback?: TFunction | object): this;
|
|
435
|
+
}
|
|
436
|
+
interface HasMany<M extends Model$1> extends HasOneOrMany<M> {
|
|
437
|
+
getResults(): Promise<ICollection<M>>;
|
|
438
|
+
}
|
|
439
|
+
interface BelongsTo<M extends Model$1> extends Relation<M> {
|
|
440
|
+
getResults(): Promise<M | null>;
|
|
441
|
+
withDefault(callback?: TFunction | object): this;
|
|
442
|
+
}
|
|
443
|
+
interface BelongsToMany<M extends Model$1> extends Relation<M> {
|
|
444
|
+
getResults(): Promise<ICollection<M>>;
|
|
445
|
+
withTimestamps(): this;
|
|
446
|
+
wherePivot(column: any, operator?: any, value?: any, boolean?: string, ...args: any[]): this;
|
|
447
|
+
wherePivotBetween(column: any, values: any, boolean?: string, not?: boolean): this;
|
|
448
|
+
orWherePivotBetween(column: any, values: any): this;
|
|
449
|
+
wherePivotNotBetween(column: any, values: any, boolean?: string): this;
|
|
450
|
+
orWherePivotNotBetween(column: any, values: any): this;
|
|
451
|
+
wherePivotIn(column: any, values: any, boolean?: string, not?: boolean): this;
|
|
452
|
+
orWherePivot(column: any, operator?: any, value?: any): this;
|
|
453
|
+
orWherePivotIn(column: any, values: any): this;
|
|
454
|
+
wherePivotNotIn(column: any, values: any, boolean?: string): this;
|
|
455
|
+
orWherePivotNotIn(column: any, values: any): this;
|
|
456
|
+
wherePivotNull(column: any, boolean?: string, not?: boolean): this;
|
|
457
|
+
wherePivotNotNull(column: any, boolean?: string): this;
|
|
458
|
+
orWherePivotNull(column: any, not?: boolean): this;
|
|
459
|
+
orWherePivotNotNull(column: any): this;
|
|
460
|
+
orderByPivot(column: any, direction?: string): this;
|
|
461
|
+
}
|
|
462
|
+
interface IModel {
|
|
463
|
+
[value: string]: any;
|
|
464
|
+
attributes: any;
|
|
465
|
+
relations: any;
|
|
466
|
+
exists: boolean;
|
|
467
|
+
primaryKey: string;
|
|
468
|
+
builder?: IBuilder<any, any> | null;
|
|
469
|
+
table: string | null;
|
|
470
|
+
connection?: TBaseConfig['client'] | null;
|
|
471
|
+
keyType: string;
|
|
472
|
+
incrementing: boolean;
|
|
473
|
+
perPage: number;
|
|
474
|
+
with: string | string[] | TGeneric<(...args: any[]) => IBuilder<Model$1>>;
|
|
475
|
+
withCount: string[];
|
|
476
|
+
trx: AnyQueryBuilder | null;
|
|
477
|
+
timestamps: boolean;
|
|
478
|
+
dateFormat: string;
|
|
479
|
+
visible: string[];
|
|
480
|
+
hidden: string[];
|
|
481
|
+
query<T extends {
|
|
482
|
+
prototype: unknown;
|
|
483
|
+
}>(this: T, client?: AnyQueryBuilder | null): IBuilder<Model$1>;
|
|
484
|
+
on<T extends {
|
|
485
|
+
prototype: unknown;
|
|
486
|
+
}>(this: T, connection: string | null): IBuilder<Model$1>;
|
|
487
|
+
boot(): void;
|
|
488
|
+
make<T extends IModel>(this: new () => T, attributes?: TGeneric): T;
|
|
489
|
+
addHook(hook: Hook, callback: TFunction): void;
|
|
490
|
+
creating(callback: TFunction): void;
|
|
491
|
+
created(callback: TFunction): void;
|
|
492
|
+
updating(callback: TFunction): void;
|
|
493
|
+
updated(callback: TFunction): void;
|
|
494
|
+
deleting(callback: TFunction): void;
|
|
495
|
+
deleted(callback: TFunction): void;
|
|
496
|
+
saving(callback: TFunction): void;
|
|
497
|
+
saved(callback: TFunction): void;
|
|
498
|
+
restoring(callback: TFunction): void;
|
|
499
|
+
restored(callback: TFunction): void;
|
|
500
|
+
trashed(callback: TFunction): void;
|
|
501
|
+
forceDeleted(callback: TFunction): void;
|
|
502
|
+
bootIfNotBooted(): void;
|
|
503
|
+
initialize(): void;
|
|
504
|
+
initializePlugins(): void;
|
|
505
|
+
addPluginInitializer(method: any): void;
|
|
506
|
+
newInstance(attributes?: TGeneric, exists?: boolean): any;
|
|
507
|
+
getKey(): string | number | null | undefined;
|
|
508
|
+
getKeyName(): string;
|
|
509
|
+
getConnectionName(): string;
|
|
510
|
+
getConnection(): any;
|
|
511
|
+
setConnection(connection: TBaseConfig['client'] | null): this;
|
|
512
|
+
usesUniqueIds(): boolean;
|
|
513
|
+
uniqueIds(): string[];
|
|
514
|
+
newUniqueId(): string;
|
|
515
|
+
setUniqueIds(): void;
|
|
516
|
+
getKeyType(): string;
|
|
517
|
+
getIncrementing(): boolean;
|
|
518
|
+
setIncrementing(value: boolean): this;
|
|
519
|
+
getTable(): string;
|
|
520
|
+
setTable(table: string): this;
|
|
521
|
+
getDates(): string[];
|
|
522
|
+
getDateFormat(): string;
|
|
523
|
+
getAttributes(): object;
|
|
524
|
+
getAttribute(key: string): any;
|
|
525
|
+
setAttribute(key: string, value: any): this;
|
|
526
|
+
fill(attributes: any): this;
|
|
527
|
+
setAppends(appends: string[]): this;
|
|
528
|
+
append(key: string | string[]): this;
|
|
529
|
+
getRelation<T extends Model$1>(relation: string): T | ICollection<T> | null | undefined;
|
|
530
|
+
setRelation<T extends Model$1>(relation: string, value: T | ICollection<T> | null): this;
|
|
531
|
+
unsetRelation(relation: string): this;
|
|
532
|
+
relationLoaded(relation: string): boolean;
|
|
533
|
+
makeVisible(attributes: string | string[]): this;
|
|
534
|
+
makeHidden(attributes: string | string[]): this;
|
|
535
|
+
newCollection(models?: any[]): ICollection<Model$1>;
|
|
536
|
+
load(relations: WithRelationType): Promise<this>;
|
|
537
|
+
load(...relations: WithRelationType[]): Promise<this>;
|
|
538
|
+
loadAggregate(relations: WithRelationType, column: any, callback?: any): Promise<this>;
|
|
539
|
+
loadCount(...relations: WithRelationType[]): Promise<this>;
|
|
540
|
+
loadMax(relations: WithRelationType, column: string): Promise<this>;
|
|
541
|
+
loadMin(relations: WithRelationType, column: string): Promise<this>;
|
|
542
|
+
loadSum(relations: WithRelationType, column: string): Promise<this>;
|
|
543
|
+
usesTimestamps(): boolean;
|
|
544
|
+
updateTimestamps(): this;
|
|
545
|
+
getCreatedAtColumn(): string;
|
|
546
|
+
getUpdatedAtColumn(): string;
|
|
547
|
+
getDeletedAtColumn(): string;
|
|
548
|
+
setCreatedAt(value: string): this;
|
|
549
|
+
setUpdatedAt(value: string): this;
|
|
550
|
+
freshTimestamp(): Date;
|
|
551
|
+
freshTimestampString(): string;
|
|
552
|
+
fromDateTime(value: Date | number | null): string;
|
|
553
|
+
useSoftDeletes(): boolean;
|
|
554
|
+
toData(): any;
|
|
555
|
+
attributesToData(): any;
|
|
556
|
+
relationsToData(): any;
|
|
557
|
+
toJSON(): any;
|
|
558
|
+
toJson(): string;
|
|
559
|
+
toString(): string;
|
|
560
|
+
isDirty(attributes?: string | string[]): boolean;
|
|
561
|
+
getDirty(): string[];
|
|
562
|
+
save(options?: any): Promise<boolean>;
|
|
563
|
+
update(attributes?: any, options?: any): Promise<boolean>;
|
|
564
|
+
increment(column: string, amount?: number, extra?: any): Promise<boolean>;
|
|
565
|
+
decrement(column: string, amount?: number, extra?: any): Promise<boolean>;
|
|
566
|
+
serializeDate(date: any): string;
|
|
567
|
+
delete(options?: any): Promise<boolean>;
|
|
568
|
+
softDelete(options?: any): Promise<boolean>;
|
|
569
|
+
forceDelete(options?: any): Promise<boolean>;
|
|
570
|
+
restore(options?: any): Promise<boolean>;
|
|
571
|
+
trashed(): boolean;
|
|
572
|
+
fresh(): Promise<this>;
|
|
573
|
+
refresh(): Promise<this | undefined>;
|
|
574
|
+
push(): Promise<boolean>;
|
|
575
|
+
is(model: this): boolean;
|
|
576
|
+
isNot(model: this): boolean;
|
|
577
|
+
related<T extends RelationNames<this>>(relation: T): ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>;
|
|
578
|
+
getRelated<T extends RelationNames<this>>(relation: T): ReturnTypeOfMethod<ReturnTypeOfMethod<this, `relation${Capitalize<SnakeToCamelCase<T>>}`>, any>;
|
|
579
|
+
hasOne<T extends Model$1>(model: new () => T, foreignKey?: string, localKey?: string): HasOne<T>;
|
|
580
|
+
hasMany<T extends Model$1>(model: new () => T, foreignKey?: string, localKey?: string): HasMany<T>;
|
|
581
|
+
belongsTo<T extends Model$1>(model: new () => T, foreignKey?: string, ownerKey?: string, relation?: string): BelongsTo<T>;
|
|
582
|
+
belongsToMany<T extends Model$1>(model: new () => T, table?: string, foreignPivotKey?: string, relatedPivotKey?: string, parentKey?: string, relatedKey?: string): BelongsToMany<T>;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
declare const BaseModel$1: (new (...args: any[]) => any) & {
|
|
586
|
+
[x: string]: any;
|
|
587
|
+
};
|
|
588
|
+
declare class Model$1 extends BaseModel$1 {
|
|
589
|
+
protected primaryKey: string;
|
|
590
|
+
protected builder: IBuilder<any, any> | null;
|
|
591
|
+
protected table: string | null;
|
|
592
|
+
protected keyType: string;
|
|
593
|
+
protected incrementing: boolean;
|
|
594
|
+
protected withCount: never[];
|
|
595
|
+
perPage: number;
|
|
596
|
+
static globalScopes: {};
|
|
597
|
+
static pluginInitializers: {};
|
|
598
|
+
static _booted: {};
|
|
599
|
+
static resolver: arquebus;
|
|
600
|
+
connection: TBaseConfig['client'] | null;
|
|
601
|
+
eagerLoad: {};
|
|
602
|
+
exists: boolean;
|
|
603
|
+
with: string | string[] | TGeneric<(...args: any[]) => IBuilder<Model$1>>;
|
|
604
|
+
trx: null;
|
|
605
|
+
constructor(attributes?: {});
|
|
606
|
+
static query(trx?: null): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
607
|
+
static on(connection?: TBaseConfig['client'] | null): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
608
|
+
static init(attributes?: {}): Model$1;
|
|
609
|
+
static extend(plugin: TFunction, options: TGeneric): void;
|
|
610
|
+
static make(attributes?: TGeneric): Model$1;
|
|
611
|
+
getConstructor<T extends typeof Model$1>(this: InstanceType<T>): T;
|
|
612
|
+
bootIfNotBooted(this: any): void;
|
|
613
|
+
static booting(): void;
|
|
614
|
+
static boot(): void;
|
|
615
|
+
static booted(): void;
|
|
616
|
+
static setConnectionResolver(resolver: arquebus): void;
|
|
617
|
+
initialize(): void;
|
|
618
|
+
initializePlugins(this: any): void;
|
|
619
|
+
addPluginInitializer(this: any, method: any): void;
|
|
620
|
+
newInstance(this: any, attributes?: TGeneric, exists?: boolean): any;
|
|
621
|
+
newFromBuilder(attributes?: TGeneric, connection?: null): any;
|
|
622
|
+
asProxy(): this;
|
|
623
|
+
getKey(): any;
|
|
624
|
+
getKeyName(): string;
|
|
625
|
+
getForeignKey(): string;
|
|
626
|
+
getConnectionName(): "mysql" | "mysql2" | "sqlite3" | "oracle" | "mariadb" | "pg";
|
|
627
|
+
getTable(): string;
|
|
628
|
+
getConnection(this: any): any;
|
|
629
|
+
setConnection(connection: TBaseConfig['client'] | null): this;
|
|
630
|
+
getKeyType(): string;
|
|
631
|
+
newQuery(trx?: null): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
632
|
+
newQueryWithoutScopes(trx?: null): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
633
|
+
newModelQuery(trx?: null): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
634
|
+
addGlobalScopes(this: any, builder: Builder<Model$1>): Builder<Model$1, IModel | ICollection<Model$1>>;
|
|
635
|
+
hasNamedScope(name: string): boolean;
|
|
636
|
+
callNamedScope(scope: string, parameters: any[]): any;
|
|
637
|
+
setTable(table: string): this;
|
|
638
|
+
newCollection(this: any, models?: never[]): Collection$1<Model$1>;
|
|
639
|
+
load<R extends WithRelationType>(this: any, ...relations: R[]): Promise<any>;
|
|
640
|
+
loadAggregate<R extends WithRelationType>(relations: R[], column: string, callback?: TFunction | string | null): Promise<this>;
|
|
641
|
+
loadCount<R extends WithRelationType>(...relations: R[]): Promise<this>;
|
|
642
|
+
loadMax<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
643
|
+
loadMin<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
644
|
+
loadSum<R extends WithRelationType>(relations: R[], column: string): Promise<this>;
|
|
645
|
+
increment(column: string, amount?: number, extra?: TGeneric, options?: TGeneric): Promise<any>;
|
|
646
|
+
decrement(column: string, amount?: number, extra?: TGeneric, options?: TGeneric): Promise<any>;
|
|
647
|
+
incrementOrDecrement(column: string, amount: number, extra: TGeneric, method: string, options: TGeneric): Promise<any>;
|
|
648
|
+
toData(): {
|
|
649
|
+
[x: string]: any;
|
|
650
|
+
[x: number]: any;
|
|
651
|
+
[x: symbol]: any;
|
|
652
|
+
};
|
|
653
|
+
toJSON(): {
|
|
654
|
+
[x: string]: any;
|
|
655
|
+
[x: number]: any;
|
|
656
|
+
[x: symbol]: any;
|
|
657
|
+
};
|
|
658
|
+
toJson(...args: any[]): string;
|
|
659
|
+
toString(): string;
|
|
660
|
+
fill(attributes: TGeneric): this;
|
|
661
|
+
transacting(trx: any): this;
|
|
662
|
+
trashed(): boolean;
|
|
663
|
+
getIncrementing(): boolean;
|
|
664
|
+
setIncrementing(value: boolean): this;
|
|
665
|
+
save(options?: TGeneric): Promise<boolean>;
|
|
666
|
+
update(attributes?: TGeneric, options?: TGeneric): Promise<boolean>;
|
|
667
|
+
delete(options?: {}): Promise<boolean>;
|
|
668
|
+
performDeleteOnModel(options?: TGeneric): Promise<void>;
|
|
669
|
+
setKeysForSaveQuery(query: any): any;
|
|
670
|
+
forceDelete(options?: {}): Promise<boolean>;
|
|
671
|
+
fresh(this: any): any;
|
|
672
|
+
refresh(this: any): Promise<any>;
|
|
673
|
+
newPivot<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists: boolean, using?: typeof Pivot$1 | null): Pivot$1;
|
|
674
|
+
qualifyColumn(column: string): string;
|
|
675
|
+
getQualifiedKeyName(): string;
|
|
676
|
+
push(options?: {}): Promise<boolean>;
|
|
677
|
+
is(model: any): any;
|
|
678
|
+
isNot(model: any): boolean;
|
|
679
|
+
}
|
|
680
|
+
declare class Pivot$1 extends Model$1 {
|
|
681
|
+
incrementing: boolean;
|
|
682
|
+
guarded: never[];
|
|
683
|
+
pivotParent: Model$1 | null;
|
|
684
|
+
foreignKey: string | null;
|
|
685
|
+
relatedKey: string | null;
|
|
686
|
+
setPivotKeys(foreignKey: string, relatedKey: string): this;
|
|
687
|
+
static fromRawAttributes<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot$1;
|
|
688
|
+
static fromAttributes<E extends Model$1>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot$1;
|
|
689
|
+
hasTimestampAttributes(this: any, attributes?: TGeneric | null): boolean;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
type TGeneric<V = any, K extends string = string> = Record<K, V>;
|
|
693
|
+
type Hook = 'creating' | 'created' | 'updating' | 'updated' | 'saving' | 'saved' | 'deleting' | 'deleted' | 'restoring' | 'restored' | 'trashed' | 'forceDeleted';
|
|
694
|
+
type TFunction<TArgs extends any[] = any[], TReturn = any> = (...args: TArgs) => TReturn;
|
|
695
|
+
type PrimitiveValue = string | number | boolean | Date | string[] | number[] | boolean[] | Date[] | null | Buffer;
|
|
696
|
+
type ReturnTypeOfMethod<T, K extends keyof T> = T[K] extends (...args: any[]) => infer R ? R : never;
|
|
697
|
+
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
|
|
698
|
+
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToSnakeCase<U>}` : `${Uncapitalize<T>}_${CamelToSnakeCase<U>}` : S;
|
|
699
|
+
type FunctionPropertyNames<T> = {
|
|
700
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
701
|
+
}[keyof T];
|
|
702
|
+
type RelationNames<T> = FunctionPropertyNames<T> extends infer R ? R extends `relation${infer P}` ? P extends ('sToData' | 'loaded') ? never : CamelToSnakeCase<P> : never : never;
|
|
703
|
+
type MixinConstructor<T = TGeneric> = new (...args: any[]) => T;
|
|
704
|
+
|
|
705
|
+
declare class Collection<I extends Model> extends Collection$2<I> {
|
|
706
|
+
mapThen(callback: TFunction): Promise<any[]>;
|
|
707
|
+
modelKeys(): any[];
|
|
708
|
+
contains<K, V>(key: keyof I | K | TFunction, value?: V): boolean;
|
|
709
|
+
diff(items: ICollection<any> | any[]): any;
|
|
710
|
+
except(keys: any[]): any;
|
|
711
|
+
intersect(items: I[]): any;
|
|
712
|
+
unique(key?: TFunction | keyof I, _strict?: boolean): any;
|
|
713
|
+
find(key: any, defaultValue?: null): any;
|
|
714
|
+
makeVisible(attributes: any): this;
|
|
715
|
+
makeHidden(attributes: any): this;
|
|
716
|
+
append(attributes: any): this;
|
|
717
|
+
only(keys: any[]): any;
|
|
718
|
+
getDictionary(items?: ICollection<any> | any[]): TGeneric;
|
|
719
|
+
toData(): ({
|
|
720
|
+
[x: string]: any;
|
|
721
|
+
[x: number]: any;
|
|
722
|
+
[x: symbol]: any;
|
|
723
|
+
} | I)[];
|
|
724
|
+
toJSON(): ({
|
|
725
|
+
[x: string]: any;
|
|
726
|
+
[x: number]: any;
|
|
727
|
+
[x: symbol]: any;
|
|
728
|
+
} | I)[];
|
|
729
|
+
toJson(...args: any[]): string;
|
|
730
|
+
[Symbol.iterator]: () => Iterator<I>;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
declare const BaseModel: (new (...args: any[]) => any) & {
|
|
734
|
+
[x: string]: any;
|
|
735
|
+
};
|
|
736
|
+
declare class Model extends BaseModel {
|
|
737
|
+
protected primaryKey: string;
|
|
738
|
+
protected perPage: number;
|
|
739
|
+
static globalScopes: {};
|
|
740
|
+
static pluginInitializers: {};
|
|
741
|
+
static _booted: {};
|
|
742
|
+
static resolver: arquebus;
|
|
743
|
+
static browser: boolean;
|
|
744
|
+
connection: TBaseConfig['client'] | null;
|
|
745
|
+
constructor(attributes?: {});
|
|
746
|
+
static init(attributes?: {}): Model;
|
|
747
|
+
static extend(plugin: TFunction, options: TGeneric): void;
|
|
748
|
+
static make(attributes?: TGeneric): Model;
|
|
749
|
+
bootIfNotBooted(this: any): void;
|
|
750
|
+
static booting(): void;
|
|
751
|
+
static boot(): void;
|
|
752
|
+
static booted(): void;
|
|
753
|
+
static setConnectionResolver(resolver: arquebus): void;
|
|
754
|
+
initialize(): void;
|
|
755
|
+
initializePlugins(this: any): void;
|
|
756
|
+
addPluginInitializer(this: any, method: any): void;
|
|
757
|
+
newInstance(this: any, attributes?: TGeneric, exists?: boolean): any;
|
|
758
|
+
asProxy(): this;
|
|
759
|
+
getKey(): any;
|
|
760
|
+
getKeyName(): string;
|
|
761
|
+
getForeignKey(): string;
|
|
762
|
+
getConnectionName(): "mysql" | "mysql2" | "sqlite3" | "oracle" | "mariadb" | "pg" | null;
|
|
763
|
+
getTable(): any;
|
|
764
|
+
setConnection(connection: TBaseConfig['client']): this;
|
|
765
|
+
getKeyType(): any;
|
|
766
|
+
hasNamedScope(name: string): boolean;
|
|
767
|
+
callNamedScope(scope: string, parameters: any): any;
|
|
768
|
+
setTable(table: string): this;
|
|
769
|
+
newCollection(models?: never[]): Collection<never>;
|
|
770
|
+
getIncrementing(): any;
|
|
771
|
+
setIncrementing(value: boolean): this;
|
|
772
|
+
toData(): {
|
|
773
|
+
[x: string]: any;
|
|
774
|
+
[x: number]: any;
|
|
775
|
+
[x: symbol]: any;
|
|
776
|
+
};
|
|
777
|
+
toJSON(): {
|
|
778
|
+
[x: string]: any;
|
|
779
|
+
[x: number]: any;
|
|
780
|
+
[x: symbol]: any;
|
|
781
|
+
};
|
|
782
|
+
toJson(...args: any[]): string;
|
|
783
|
+
toString(): string;
|
|
784
|
+
fill(attributes: TGeneric): this;
|
|
785
|
+
transacting(trx: any): this;
|
|
786
|
+
trashed(): boolean;
|
|
787
|
+
newPivot<E extends Model>(parent: E, attributes: TGeneric, table: string, exists: boolean, using?: typeof Pivot | null): Pivot;
|
|
788
|
+
qualifyColumn(column: string): string;
|
|
789
|
+
getQualifiedKeyName(): string;
|
|
790
|
+
is(model: any): any;
|
|
791
|
+
isNot(model: any): boolean;
|
|
792
|
+
}
|
|
793
|
+
declare class Pivot extends Model {
|
|
794
|
+
incrementing: boolean;
|
|
795
|
+
guarded: never[];
|
|
796
|
+
pivotParent: Model | null;
|
|
797
|
+
foreignKey: string | null;
|
|
798
|
+
relatedKey: string | null;
|
|
799
|
+
setPivotKeys(foreignKey: string, relatedKey: string): this;
|
|
800
|
+
static fromRawAttributes<E extends Model>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot;
|
|
801
|
+
static fromAttributes<E extends Model>(parent: E, attributes: TGeneric, table: string, exists?: boolean): Pivot;
|
|
802
|
+
hasTimestampAttributes(this: any, attributes?: TGeneric | null): boolean;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
interface ICollection<T extends Model$1 | Model> extends Collection$2<T> {
|
|
806
|
+
items?: T[];
|
|
807
|
+
load(...relations: T[]): Promise<ICollection<T>>;
|
|
808
|
+
loadAggregate(relations: T | T[], column: string, action?: string | null): Promise<this>;
|
|
809
|
+
loadCount(relation: T, column: string): Promise<this>;
|
|
810
|
+
loadMax(relation: T, column: string): Promise<this>;
|
|
811
|
+
loadMin(relation: T, column: string): Promise<this>;
|
|
812
|
+
loadSum(relation: T, column: string): Promise<this>;
|
|
813
|
+
loadAvg(relation: T, column: string): Promise<this>;
|
|
814
|
+
mapThen(callback: () => void): Promise<any>;
|
|
815
|
+
modelKeys(): string[] | number[];
|
|
816
|
+
contains(key: IModel | any, operator?: any, value?: any): boolean;
|
|
817
|
+
diff(items: ICollection<T> | any[]): ICollection<T>;
|
|
818
|
+
except(keys: any[]): ICollection<T>;
|
|
819
|
+
intersect(items: T[]): ICollection<T>;
|
|
820
|
+
unique(key?: any, strict?: boolean): ICollection<T>;
|
|
821
|
+
find(key: any, defaultValue?: any): any;
|
|
822
|
+
fresh(withs?: any[]): Promise<ICollection<T>>;
|
|
823
|
+
makeVisible(attributes: string | string[]): this;
|
|
824
|
+
makeHidden(attributes: string | string[]): this;
|
|
825
|
+
append(attributes: string[]): this;
|
|
826
|
+
only(keys: null | any[]): this;
|
|
827
|
+
getDictionary(items?: any[]): TGeneric;
|
|
828
|
+
toQuery(): IBuilder<T, any>;
|
|
829
|
+
toData(): any;
|
|
830
|
+
toJSON(): any;
|
|
831
|
+
toJson(): string;
|
|
832
|
+
toString(): string;
|
|
833
|
+
[key: string]: any;
|
|
834
|
+
[Symbol.iterator]: () => Iterator<T>;
|
|
835
|
+
}
|
|
836
|
+
interface IPaginatorParams {
|
|
837
|
+
current_page: number;
|
|
838
|
+
data: any[];
|
|
839
|
+
per_page: number;
|
|
840
|
+
total: number;
|
|
841
|
+
last_page: number;
|
|
842
|
+
count: number;
|
|
843
|
+
}
|
|
844
|
+
interface IPaginator<T extends Model$1 | Model, K extends IPaginatorParams = IPaginatorParams> {
|
|
845
|
+
formatter?(paginator: IPaginator<any>): any | null;
|
|
846
|
+
setFormatter?(formatter: (paginator: IPaginator<any>) => any | null): void;
|
|
847
|
+
setItems(items: T[] | Collection$1<T>): void;
|
|
848
|
+
hasMorePages(): boolean;
|
|
849
|
+
get(index: number): T | null;
|
|
850
|
+
count(): number;
|
|
851
|
+
items(): Collection$1<T>;
|
|
852
|
+
map(callback: (value: T, index: number) => T): Collection$1<T>;
|
|
853
|
+
currentPage(): number;
|
|
854
|
+
perPage(): number;
|
|
855
|
+
lastPage(): number;
|
|
856
|
+
firstItem(): number | null;
|
|
857
|
+
lastItem(): number | null;
|
|
858
|
+
total(): number;
|
|
859
|
+
toData<U = K>(): U;
|
|
860
|
+
toJSON<U = K>(): U;
|
|
861
|
+
toJson(): string;
|
|
862
|
+
[Symbol.iterator]?(): {
|
|
863
|
+
next: () => {
|
|
864
|
+
value: T;
|
|
865
|
+
done: boolean;
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
interface IScope {
|
|
871
|
+
apply(builder: Builder<any>, model: Model$1): void;
|
|
872
|
+
}
|
|
873
|
+
interface IBuilder<M extends Model$1 | Model, R = ICollection<M> | IModel> extends IQueryBuilder<M, R> {
|
|
874
|
+
asProxy(): IQueryBuilder<M, R>;
|
|
875
|
+
enforceOrderBy(): void;
|
|
876
|
+
insert(attributes: any): Promise<any>;
|
|
877
|
+
update(attributes: any): Promise<any>;
|
|
878
|
+
increment(column: string, amount?: number, extra?: any): Promise<any>;
|
|
879
|
+
decrement(column: string, amount?: number, extra?: any): Promise<any>;
|
|
880
|
+
addUpdatedAtColumn(values: any): any;
|
|
881
|
+
delete(): Promise<boolean | number>;
|
|
882
|
+
softDelete(): boolean | Promise<any>;
|
|
883
|
+
forceDelete(): boolean | Promise<any>;
|
|
884
|
+
restore(): boolean | Promise<any>;
|
|
885
|
+
withTrashed(): this;
|
|
886
|
+
withoutTrashed(): this;
|
|
887
|
+
onlyTrashed(): this;
|
|
888
|
+
getDeletedAtColumn(): string;
|
|
889
|
+
create(attributes?: any): Promise<M>;
|
|
890
|
+
newModelInstance(attributes?: any): M;
|
|
891
|
+
count(columns?: string): Promise<number>;
|
|
892
|
+
getQuery(): AnyQueryBuilder;
|
|
893
|
+
getModel(): M;
|
|
894
|
+
setModel(model: M): this;
|
|
895
|
+
setTable(table: string): this;
|
|
896
|
+
applyScopes(): this;
|
|
897
|
+
scopes(scopes: string[]): this;
|
|
898
|
+
withGlobalScope(identifier: string | number, scope: string | (() => void)): this;
|
|
899
|
+
withoutGlobalScope(scope: IScope | string): this;
|
|
900
|
+
with(relation: WithRelationType): this;
|
|
901
|
+
with(...relations: WithRelationType[]): this;
|
|
902
|
+
has(relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
903
|
+
orHas(relation: string, operator?: any, count?: number): this;
|
|
904
|
+
doesntHave(relation: string, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
905
|
+
orDoesntHave(relation: string): this;
|
|
906
|
+
whereHas(relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
|
|
907
|
+
orWhereHas(relation: string, callback?: (builder: IBuilder<any>) => void | IBuilder<any> | null, operator?: any, count?: number): this;
|
|
908
|
+
whereRelation(relation: string, column: string, operator?: any, value?: any): this;
|
|
909
|
+
hasNested(relation: string, operator?: any, count?: number, boolean?: any, callback?: (builder: IBuilder<any>) => void | null): this;
|
|
910
|
+
canUseExistsForExistenceCheck(operator: string, count: number): boolean;
|
|
911
|
+
addHasWhere(hasQuery: IBuilder<any>, relation: string, operator?: string, count?: number, boolean?: string): this;
|
|
912
|
+
withAggregate(relations: string | string[] | object, column: string, action?: string | null): this;
|
|
913
|
+
toSql(): object;
|
|
914
|
+
withCount(...relations: WithRelationType[]): this;
|
|
915
|
+
withMax(relation: WithRelationType, column: string): this;
|
|
916
|
+
withMin(relation: WithRelationType, column: string): this;
|
|
917
|
+
withAvg(relation: WithRelationType, column: string): this;
|
|
918
|
+
withSum(relation: WithRelationType, column: string): this;
|
|
919
|
+
withExists(relation: WithRelationType): this;
|
|
920
|
+
related(relation: string): this;
|
|
921
|
+
first(column?: string | string[]): Promise<M | null | undefined>;
|
|
922
|
+
firstOrFail(column?: string | string[]): Promise<M>;
|
|
923
|
+
findOrFail(key: string | number, columns?: string[]): Promise<M>;
|
|
924
|
+
findOrFail(key: string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
|
|
925
|
+
findOrFail(key: string | number | string[] | number[] | ICollection<any>, columns?: string[]): Promise<M>;
|
|
926
|
+
findOrNew(id: string | number, columns?: string[]): Promise<M>;
|
|
927
|
+
firstOrNew(attributes?: object, values?: object): Promise<M>;
|
|
928
|
+
firstOrCreate(attributes?: object, values?: object): Promise<M>;
|
|
929
|
+
updateOrCreate(attributes: object, values?: object): Promise<M>;
|
|
930
|
+
latest(column?: string): this;
|
|
931
|
+
oldest(column?: string): this;
|
|
932
|
+
find(key: string | number, columns?: string[]): Promise<M | null | undefined>;
|
|
933
|
+
findMany(keys: string[] | number[] | ICollection<any>, columns?: string[]): Promise<ICollection<M>>;
|
|
934
|
+
pluck<X extends Model$1 = any | M>(column: string): Promise<ICollection<X>>;
|
|
935
|
+
all(columns?: string[]): Promise<ICollection<M>>;
|
|
936
|
+
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
937
|
+
[value: string]: any;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
type Operator = string;
|
|
941
|
+
type ColumnRef = string | Raw;
|
|
942
|
+
type FieldExpression = string;
|
|
943
|
+
type TableRef<QB extends AnyQueryBuilder> = ColumnRef | AnyQueryBuilder | CallbackVoid<QB>;
|
|
944
|
+
type Selection<QB extends AnyQueryBuilder> = ColumnRef | AnyQueryBuilder | CallbackVoid<QB>;
|
|
945
|
+
type QBOrCallback<QB extends AnyQueryBuilder> = AnyQueryBuilder | CallbackVoid<QB>;
|
|
946
|
+
interface CallbackVoid<T> {
|
|
947
|
+
(this: T, arg: T): void;
|
|
948
|
+
}
|
|
949
|
+
type Raw = Knex$1.Raw;
|
|
950
|
+
type OrderByDirection = 'asc' | 'desc' | 'ASC' | 'DESC';
|
|
951
|
+
interface OrderByDescriptor {
|
|
952
|
+
column: ColumnRef;
|
|
953
|
+
order?: OrderByDirection;
|
|
954
|
+
}
|
|
955
|
+
type AnyQueryBuilder<M extends Model$1 = any, R = any> = IQueryBuilder<M, R> | IBuilder<M, R>;
|
|
956
|
+
type Expression<T> = T | Raw | AnyQueryBuilder;
|
|
957
|
+
type ColumnRefOrOrderByDescriptor = ColumnRef | OrderByDescriptor;
|
|
958
|
+
interface RawInterface<R> {
|
|
959
|
+
(sql: string, ...bindings: any[]): R;
|
|
960
|
+
}
|
|
961
|
+
interface BaseSetOperations<QB extends AnyQueryBuilder> {
|
|
962
|
+
(callbackOrBuilder: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
963
|
+
(callbacksOrBuilders: QBOrCallback<QB>[], wrap?: boolean): QB;
|
|
964
|
+
}
|
|
965
|
+
type JoinRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
966
|
+
type OrderByRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
967
|
+
type WhereRawMethod<QB extends AnyQueryBuilder> = RawInterface<QB> & {};
|
|
968
|
+
interface GroupByMethod<QB extends AnyQueryBuilder> {
|
|
969
|
+
(...columns: ColumnRef[]): QB;
|
|
970
|
+
(columns: ColumnRef[]): QB;
|
|
971
|
+
}
|
|
972
|
+
type WithRelationType = {
|
|
973
|
+
[key: string]: <T extends IBuilder<any>>(builder: T) => T | void;
|
|
974
|
+
} | string | string[];
|
|
975
|
+
interface SetOperationsMethod<QB extends AnyQueryBuilder> extends BaseSetOperations<QB> {
|
|
976
|
+
(...callbacksOrBuilders: QBOrCallback<QB>[]): QB;
|
|
977
|
+
}
|
|
978
|
+
interface SelectMethod<QB extends AnyQueryBuilder> {
|
|
979
|
+
<QBP extends QB>(...columns: Selection<QBP>[]): QB;
|
|
980
|
+
<QBP extends QB>(columns: Selection<QBP>[]): QB;
|
|
981
|
+
}
|
|
982
|
+
interface WhereMethod<QB extends AnyQueryBuilder> {
|
|
983
|
+
(col: ColumnRef, op: Operator, expr: Expression<PrimitiveValue>): QB;
|
|
984
|
+
(col: ColumnRef, expr: Expression<PrimitiveValue>): QB;
|
|
985
|
+
(condition: boolean): QB;
|
|
986
|
+
(cb: CallbackVoid<QB>): QB;
|
|
987
|
+
(raw: Raw): QB;
|
|
988
|
+
<QBA extends AnyQueryBuilder>(qb: QBA): QB;
|
|
989
|
+
(obj: object): QB;
|
|
990
|
+
}
|
|
991
|
+
interface WhereWrappedMethod<QB extends AnyQueryBuilder> {
|
|
992
|
+
(cb: CallbackVoid<QB>): QB;
|
|
993
|
+
}
|
|
994
|
+
interface WhereFieldExpressionMethod<QB extends AnyQueryBuilder> {
|
|
995
|
+
(fieldExpression: FieldExpression): QB;
|
|
996
|
+
}
|
|
997
|
+
interface WhereExistsMethod<QB extends AnyQueryBuilder> {
|
|
998
|
+
(cb: CallbackVoid<QB>): QB;
|
|
999
|
+
(raw: Raw): QB;
|
|
1000
|
+
<QBA extends AnyQueryBuilder>(qb: QBA): QB;
|
|
1001
|
+
}
|
|
1002
|
+
interface WhereInMethod<QB extends AnyQueryBuilder> {
|
|
1003
|
+
(col: ColumnRef | ColumnRef[], expr: Expression<PrimitiveValue>[]): QB;
|
|
1004
|
+
(col: ColumnRef | ColumnRef[], cb: CallbackVoid<QB>): QB;
|
|
1005
|
+
(col: ColumnRef | ColumnRef[], qb: AnyQueryBuilder): QB;
|
|
1006
|
+
}
|
|
1007
|
+
interface WhereBetweenMethod<QB extends AnyQueryBuilder> {
|
|
1008
|
+
(column: ColumnRef, range: [Expression<PrimitiveValue>, Expression<PrimitiveValue>]): QB;
|
|
1009
|
+
}
|
|
1010
|
+
interface WhereNullMethod<QB extends AnyQueryBuilder> {
|
|
1011
|
+
(column: ColumnRef): QB;
|
|
1012
|
+
}
|
|
1013
|
+
interface OrderByMethod<QB extends AnyQueryBuilder> {
|
|
1014
|
+
(column: ColumnRef, order?: OrderByDirection): QB;
|
|
1015
|
+
(columns: ColumnRefOrOrderByDescriptor[]): QB;
|
|
1016
|
+
}
|
|
1017
|
+
interface WhereJsonExpressionMethod<QB extends AnyQueryBuilder> {
|
|
1018
|
+
(fieldExpression: FieldExpression, keys: string | string[]): QB;
|
|
1019
|
+
}
|
|
1020
|
+
interface WhereColumnMethod<QB extends AnyQueryBuilder> {
|
|
1021
|
+
(col1: ColumnRef, op: Operator, col2: ColumnRef): QB;
|
|
1022
|
+
(col1: ColumnRef, col2: ColumnRef): QB;
|
|
1023
|
+
}
|
|
1024
|
+
interface UnionMethod<QB extends AnyQueryBuilder> extends BaseSetOperations<QB> {
|
|
1025
|
+
(arg1: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1026
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1027
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1028
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1029
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1030
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1031
|
+
(arg1: QBOrCallback<QB>, arg2: QBOrCallback<QB>, arg3: QBOrCallback<QB>, arg4: QBOrCallback<QB>, arg5: QBOrCallback<QB>, arg6: QBOrCallback<QB>, arg7: QBOrCallback<QB>, wrap?: boolean): QB;
|
|
1032
|
+
}
|
|
1033
|
+
interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
1034
|
+
(table: TableRef<QB>, leftCol: ColumnRef, op: Operator, rightCol: ColumnRef): QB;
|
|
1035
|
+
(table: TableRef<QB>, leftCol: ColumnRef, rightCol: ColumnRef): QB;
|
|
1036
|
+
(table: TableRef<QB>, cb: CallbackVoid<Knex$1.JoinClause>): QB;
|
|
1037
|
+
(table: TableRef<QB>, raw: Raw): QB;
|
|
1038
|
+
(raw: Raw): QB;
|
|
1039
|
+
}
|
|
1040
|
+
interface JoinMethod<QB extends AnyQueryBuilder> {
|
|
1041
|
+
(table: TableRef<QB>, leftCol: ColumnRef, op: Operator, rightCol: ColumnRef): QB;
|
|
1042
|
+
(table: TableRef<QB>, leftCol: ColumnRef, rightCol: ColumnRef): QB;
|
|
1043
|
+
(table: TableRef<QB>, cb: CallbackVoid<Knex$1.JoinClause>): QB;
|
|
1044
|
+
(table: TableRef<QB>, raw: Raw): QB;
|
|
1045
|
+
(raw: Raw): QB;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
interface SchemaBuilder extends Knex$1.SchemaBuilder {
|
|
1049
|
+
[k: string]: any;
|
|
1050
|
+
}
|
|
1051
|
+
interface AsMethod<QB extends AnyQueryBuilder> {
|
|
1052
|
+
(alias: string): QB;
|
|
1053
|
+
}
|
|
1054
|
+
interface IStatement {
|
|
1055
|
+
grouping: string;
|
|
1056
|
+
direction: string;
|
|
1057
|
+
type: string;
|
|
1058
|
+
value: () => any;
|
|
1059
|
+
not: boolean;
|
|
1060
|
+
nulls: boolean;
|
|
1061
|
+
bool: 'and' | 'or' | 'not';
|
|
1062
|
+
}
|
|
1063
|
+
interface IQueryBuilder<M extends Model$1 | Model = Model$1, R = M[] | M> {
|
|
1064
|
+
schema: SchemaBuilder;
|
|
1065
|
+
_statements: IStatement[];
|
|
1066
|
+
table(name: string): IQueryBuilder<M, R>;
|
|
1067
|
+
select: SelectMethod<this>;
|
|
1068
|
+
columns: SelectMethod<this>;
|
|
1069
|
+
column: SelectMethod<this>;
|
|
1070
|
+
distinct: SelectMethod<this>;
|
|
1071
|
+
distinctOn: SelectMethod<this>;
|
|
1072
|
+
as: AsMethod<this>;
|
|
1073
|
+
asProxy(): IQueryBuilder<M, R>;
|
|
1074
|
+
where: WhereMethod<this>;
|
|
1075
|
+
andWhere: WhereMethod<this>;
|
|
1076
|
+
orWhere(...args: any[]): this;
|
|
1077
|
+
whereNot: WhereMethod<this>;
|
|
1078
|
+
andWhereNot: WhereMethod<this>;
|
|
1079
|
+
orWhereNot: WhereMethod<this>;
|
|
1080
|
+
whereRaw: WhereRawMethod<this>;
|
|
1081
|
+
orWhereRaw: WhereRawMethod<this>;
|
|
1082
|
+
andWhereRaw: WhereRawMethod<this>;
|
|
1083
|
+
whereWrapped: WhereWrappedMethod<this>;
|
|
1084
|
+
havingWrapped: WhereWrappedMethod<this>;
|
|
1085
|
+
whereExists: WhereExistsMethod<this>;
|
|
1086
|
+
orWhereExists: WhereExistsMethod<this>;
|
|
1087
|
+
whereNotExists: WhereExistsMethod<this>;
|
|
1088
|
+
orWhereNotExists: WhereExistsMethod<this>;
|
|
1089
|
+
whereIn: WhereInMethod<this>;
|
|
1090
|
+
orWhereIn: WhereInMethod<this>;
|
|
1091
|
+
whereNotIn: WhereInMethod<this>;
|
|
1092
|
+
orWhereNotIn: WhereInMethod<this>;
|
|
1093
|
+
whereBetween: WhereBetweenMethod<this>;
|
|
1094
|
+
orWhereBetween: WhereBetweenMethod<this>;
|
|
1095
|
+
andWhereBetween: WhereBetweenMethod<this>;
|
|
1096
|
+
whereNotBetween: WhereBetweenMethod<this>;
|
|
1097
|
+
orWhereNotBetween: WhereBetweenMethod<this>;
|
|
1098
|
+
andWhereNotBetween: WhereBetweenMethod<this>;
|
|
1099
|
+
whereNull: WhereNullMethod<this>;
|
|
1100
|
+
orWhereNull: WhereNullMethod<this>;
|
|
1101
|
+
whereNotNull: WhereNullMethod<this>;
|
|
1102
|
+
orWhereNotNull: WhereNullMethod<this>;
|
|
1103
|
+
whereColumn: WhereColumnMethod<this>;
|
|
1104
|
+
orWhereColumn: WhereColumnMethod<this>;
|
|
1105
|
+
andWhereColumn: WhereColumnMethod<this>;
|
|
1106
|
+
whereNotColumn: WhereColumnMethod<this>;
|
|
1107
|
+
orWhereNotColumn: WhereColumnMethod<this>;
|
|
1108
|
+
andWhereNotColumn: WhereColumnMethod<this>;
|
|
1109
|
+
whereJsonIsArray: WhereFieldExpressionMethod<this>;
|
|
1110
|
+
orWhereJsonIsArray: WhereFieldExpressionMethod<this>;
|
|
1111
|
+
whereJsonNotArray: WhereFieldExpressionMethod<this>;
|
|
1112
|
+
orWhereJsonNotArray: WhereFieldExpressionMethod<this>;
|
|
1113
|
+
whereJsonIsObject: WhereFieldExpressionMethod<this>;
|
|
1114
|
+
orWhereJsonIsObject: WhereFieldExpressionMethod<this>;
|
|
1115
|
+
whereJsonNotObject: WhereFieldExpressionMethod<this>;
|
|
1116
|
+
orWhereJsonNotObject: WhereFieldExpressionMethod<this>;
|
|
1117
|
+
whereJsonHasAny: WhereJsonExpressionMethod<this>;
|
|
1118
|
+
orWhereJsonHasAny: WhereJsonExpressionMethod<this>;
|
|
1119
|
+
whereJsonHasAll: WhereJsonExpressionMethod<this>;
|
|
1120
|
+
orWhereJsonHasAll: WhereJsonExpressionMethod<this>;
|
|
1121
|
+
having: WhereMethod<this>;
|
|
1122
|
+
andHaving: WhereMethod<this>;
|
|
1123
|
+
orHaving: WhereMethod<this>;
|
|
1124
|
+
havingRaw: WhereRawMethod<this>;
|
|
1125
|
+
orHavingRaw: WhereRawMethod<this>;
|
|
1126
|
+
havingIn: WhereInMethod<this>;
|
|
1127
|
+
orHavingIn: WhereInMethod<this>;
|
|
1128
|
+
havingNotIn: WhereInMethod<this>;
|
|
1129
|
+
orHavingNotIn: WhereInMethod<this>;
|
|
1130
|
+
havingNull: WhereNullMethod<this>;
|
|
1131
|
+
orHavingNull: WhereNullMethod<this>;
|
|
1132
|
+
havingNotNull: WhereNullMethod<this>;
|
|
1133
|
+
orHavingNotNull: WhereNullMethod<this>;
|
|
1134
|
+
havingExists: WhereExistsMethod<this>;
|
|
1135
|
+
orHavingExists: WhereExistsMethod<this>;
|
|
1136
|
+
havingNotExists: WhereExistsMethod<this>;
|
|
1137
|
+
orHavingNotExists: WhereExistsMethod<this>;
|
|
1138
|
+
havingBetween: WhereBetweenMethod<this>;
|
|
1139
|
+
orHavingBetween: WhereBetweenMethod<this>;
|
|
1140
|
+
havingNotBetween: WhereBetweenMethod<this>;
|
|
1141
|
+
orHavingNotBetween: WhereBetweenMethod<this>;
|
|
1142
|
+
union: UnionMethod<this>;
|
|
1143
|
+
unionAll: UnionMethod<this>;
|
|
1144
|
+
intersect: SetOperationsMethod<this>;
|
|
1145
|
+
join: JoinMethod<this>;
|
|
1146
|
+
joinRaw: JoinRawMethod<this>;
|
|
1147
|
+
innerJoin: JoinMethod<this>;
|
|
1148
|
+
leftJoin: JoinMethod<this>;
|
|
1149
|
+
leftOuterJoin: JoinMethod<this>;
|
|
1150
|
+
rightJoin: JoinMethod<this>;
|
|
1151
|
+
rightOuterJoin: JoinMethod<this>;
|
|
1152
|
+
outerJoin: JoinMethod<this>;
|
|
1153
|
+
fullOuterJoin: JoinMethod<this>;
|
|
1154
|
+
crossJoin: JoinMethod<this>;
|
|
1155
|
+
orderBy: OrderByMethod<this>;
|
|
1156
|
+
orderByRaw: OrderByRawMethod<this>;
|
|
1157
|
+
groupBy: GroupByMethod<this>;
|
|
1158
|
+
groupByRaw: RawInterface<this>;
|
|
1159
|
+
transaction(callback?: TFunction): Promise<Knex$1.Transaction> | undefined;
|
|
1160
|
+
destroy(callback: TFunction): Promise<number>;
|
|
1161
|
+
destroy(): Promise<number>;
|
|
1162
|
+
clone(): IQueryBuilder<M, R>;
|
|
1163
|
+
raw: Knex$1.RawQueryBuilder<TGeneric, M>;
|
|
1164
|
+
get(columns?: string[]): Promise<any>;
|
|
1165
|
+
first(columns?: string[]): Promise<M | null | undefined>;
|
|
1166
|
+
find(key: string | number, columns?: string[]): Promise<M | null | undefined>;
|
|
1167
|
+
insert(attributes: any): Promise<unknown>;
|
|
1168
|
+
update(...attributes: any[]): Promise<number>;
|
|
1169
|
+
delete(): Promise<boolean | number>;
|
|
1170
|
+
exists(): Promise<boolean>;
|
|
1171
|
+
count(column?: string): Promise<number>;
|
|
1172
|
+
min(column: string): Promise<number>;
|
|
1173
|
+
max(column: string): Promise<number>;
|
|
1174
|
+
sum(column: string): Promise<number>;
|
|
1175
|
+
avg(column: string): Promise<number>;
|
|
1176
|
+
skip(count: number): this;
|
|
1177
|
+
take(count: number): this;
|
|
1178
|
+
limit(count: number): this;
|
|
1179
|
+
offset(count: number): this;
|
|
1180
|
+
pluck<X extends Model$1 = any>(column: string): Promise<ICollection<X>>;
|
|
1181
|
+
chunk(count: number, callback: (rows: M[]) => any): Promise<boolean>;
|
|
1182
|
+
forPage(page: number, perPage?: number): this;
|
|
1183
|
+
paginate<F extends IPaginatorParams>(page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
declare const Inference$1: {
|
|
1187
|
+
new <M extends Model$1 = Model$1, R = M[] | M>(): IQueryBuilder<M, R>;
|
|
1188
|
+
};
|
|
1189
|
+
declare class QueryBuilder<M extends Model$1 = Model$1, R = M[] | M> extends Inference$1<M, R> {
|
|
1190
|
+
model: M;
|
|
1191
|
+
schema: SchemaBuilder;
|
|
1192
|
+
private connector;
|
|
1193
|
+
constructor(config: TConfig | null, connector: TFunction);
|
|
1194
|
+
asProxy(): any;
|
|
1195
|
+
beginTransaction(): Promise<Knex$1.Transaction<any, any[]> | undefined>;
|
|
1196
|
+
table<X extends M>(table: string): IQueryBuilder<X, R>;
|
|
1197
|
+
transaction(callback?: TFunction): Promise<Knex$1.Transaction> | undefined;
|
|
1198
|
+
find(id: string | number, columns?: string[]): Promise<any>;
|
|
1199
|
+
get(_columns?: string[]): Promise<any>;
|
|
1200
|
+
exists(): Promise<boolean>;
|
|
1201
|
+
skip(this: any, ...args: any[]): any;
|
|
1202
|
+
take(this: any, ...args: any[]): any;
|
|
1203
|
+
chunk(count: number, callback: TFunction): Promise<boolean>;
|
|
1204
|
+
paginate<F extends IPaginatorParams>(this: any, page?: number, perPage?: number): Promise<IPaginator<M, F>>;
|
|
1205
|
+
forPage(this: any, page?: number, perPage?: number): any;
|
|
1206
|
+
toSQL(...args: Parameters<typeof this$1.connector.toSQL>): Knex$1.Sql;
|
|
1207
|
+
count(column: string): Promise<number>;
|
|
1208
|
+
min(column: string): Promise<number>;
|
|
1209
|
+
max(column: string): Promise<number>;
|
|
1210
|
+
sum(column: string): Promise<number>;
|
|
1211
|
+
avg(column: string): Promise<number>;
|
|
1212
|
+
clone(): IQueryBuilder<M, R>;
|
|
1213
|
+
delete(): Promise<number | boolean>;
|
|
1214
|
+
insert(...args: Parameters<typeof this$1.connector.insert>): Promise<unknown>;
|
|
1215
|
+
update(...args: Parameters<typeof this$1.connector.update>): Promise<number>;
|
|
1216
|
+
destroy(...args: Parameters<typeof this$1.connector.destroy>): Promise<number>;
|
|
1217
|
+
get _statements(): IStatement[] & any[];
|
|
1218
|
+
get _single(): any;
|
|
1219
|
+
get from(): Knex$1.Table<any, any>;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
interface IMigration {
|
|
1223
|
+
withinTransaction?: boolean;
|
|
1224
|
+
up(schema: SchemaBuilder, connection?: QueryBuilder): Promise<any>;
|
|
1225
|
+
down(schema: SchemaBuilder, connection?: QueryBuilder): Promise<any>;
|
|
1226
|
+
getConnection(): TBaseConfig['client'];
|
|
1227
|
+
}
|
|
1228
|
+
declare const Inference: {
|
|
1229
|
+
new (): IMigration;
|
|
1230
|
+
};
|
|
1231
|
+
declare class Migration extends Inference {
|
|
1232
|
+
protected connection: TBaseConfig['client'];
|
|
1233
|
+
withinTransaction: boolean;
|
|
1234
|
+
getConnection(): TBaseConfig['client'];
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
type migration_IMigration = IMigration;
|
|
1238
|
+
type migration_Migration = Migration;
|
|
1239
|
+
declare const migration_Migration: typeof Migration;
|
|
1240
|
+
declare namespace migration {
|
|
1241
|
+
export { type migration_IMigration as IMigration, migration_Migration as Migration, Migration as default };
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
declare class MigrationCreator {
|
|
1245
|
+
private customStubPath?;
|
|
1246
|
+
private type;
|
|
1247
|
+
private postCreate;
|
|
1248
|
+
constructor(customStubPath?: string | undefined, type?: 'ts' | 'js');
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a new migration file
|
|
1251
|
+
*
|
|
1252
|
+
* @param name
|
|
1253
|
+
* @param dir
|
|
1254
|
+
* @param table
|
|
1255
|
+
* @param create
|
|
1256
|
+
* @returns
|
|
1257
|
+
*/
|
|
1258
|
+
create(name: string, dir: string, table: string, create?: boolean): Promise<string>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Publish migrations from third party vendors
|
|
1261
|
+
*
|
|
1262
|
+
* @param dir
|
|
1263
|
+
* @param callback
|
|
1264
|
+
*/
|
|
1265
|
+
publish(dir: string, callback?: (name: string, source: string, dest: string) => void): Promise<void>;
|
|
1266
|
+
getStub(table?: string, create?: boolean): string;
|
|
1267
|
+
populateStub(stub: string, table: string): string;
|
|
1268
|
+
getClassName(name: string): string;
|
|
1269
|
+
getPath(name: string, dir: string): string;
|
|
1270
|
+
firePostCreateHooks(table: string, filePath: string): Promise<void>;
|
|
1271
|
+
afterCreate(callback: TFunction): void;
|
|
1272
|
+
ensureDirectoryExists(dir: string): Promise<void>;
|
|
1273
|
+
stubPath(stub?: string): string;
|
|
1274
|
+
getDirname(meta: ImportMeta | null): string;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
declare namespace migrationCreator {
|
|
1278
|
+
export { MigrationCreator as default };
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
export { migration as Migration, migrationCreator as MigrationCreator, migrationRepository as MigrationRepository, migrator as Migrator };
|