1 |
|
2 | declare module '@ioc:Adonis/Lucid/Database' {
|
3 | import { Knex } from 'knex';
|
4 | import { DialectContract, QueryClientContract, TransactionClientContract } from '@ioc:Adonis/Lucid/Database';
|
5 | |
6 |
|
7 |
|
8 | type Dictionary<T, K extends string | number = string> = {
|
9 | [key in K]: T;
|
10 | };
|
11 | |
12 |
|
13 |
|
14 | type OneOrMany<T> = T | T[];
|
15 | |
16 |
|
17 |
|
18 |
|
19 | type ValueWithSubQueries<T> = T | ChainableContract | RawQuery;
|
20 | |
21 |
|
22 |
|
23 | type RawQuery = RawBuilderContract | RawQueryBuilderContract | Knex.Raw | Knex.RawQueryBuilder;
|
24 | |
25 |
|
26 |
|
27 |
|
28 | type StrictValues = string | number | boolean | Date | Array<string> | Array<number> | Array<Date> | Array<boolean> | Buffer | RawQuery | ReferenceBuilderContract;
|
29 | |
30 |
|
31 |
|
32 | type StrictValuesWithoutRaw = Exclude<StrictValues, RawQuery>;
|
33 | |
34 |
|
35 |
|
36 | type RawQueryBindings = {
|
37 | [key: string]: StrictValues;
|
38 | } | StrictValues[];
|
39 | |
40 |
|
41 |
|
42 |
|
43 | interface RawQueryFn<Builder extends ChainableContract> {
|
44 | (sql: string | RawQuery): Builder;
|
45 | (sql: string, bindings: RawQueryBindings): Builder;
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 | type QueryCallback<Builder> = (builder: Builder) => void;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | type DBQueryCallback = (userFn: QueryCallback<ChainableContract>, keysResolver?: (columnName: string) => string) => (builder: Knex.QueryBuilder) => void;
|
64 | |
65 |
|
66 |
|
67 | interface DatabaseQueryBuilderSelect<Builder extends ChainableContract> {
|
68 | |
69 |
|
70 |
|
71 |
|
72 | (columns: Dictionary<string, string>): Builder;
|
73 | |
74 |
|
75 |
|
76 | (columns: ValueWithSubQueries<string | number>[]): Builder;
|
77 | |
78 |
|
79 |
|
80 | (...columns: ValueWithSubQueries<string | number>[]): Builder;
|
81 | |
82 |
|
83 |
|
84 | (column: '*'): Builder;
|
85 | }
|
86 | |
87 |
|
88 |
|
89 | interface Where<Builder extends ChainableContract> {
|
90 | |
91 |
|
92 |
|
93 | (callback: QueryCallback<Builder>): Builder;
|
94 | |
95 |
|
96 |
|
97 | (clause: Dictionary<any, string>): Builder;
|
98 | |
99 |
|
100 |
|
101 | (key: string | RawQuery, value: StrictValues | ChainableContract): Builder;
|
102 | (key: string | RawQuery, operator: string, value: StrictValues | ChainableContract): Builder;
|
103 | }
|
104 | |
105 |
|
106 |
|
107 | interface WhereLike<Builder extends ChainableContract> {
|
108 | |
109 |
|
110 |
|
111 | (key: string, value: StrictValues | ChainableContract): Builder;
|
112 | }
|
113 | |
114 |
|
115 |
|
116 | interface WhereJson<Builder extends ChainableContract> {
|
117 | |
118 |
|
119 |
|
120 | (column: string, value: Record<string, any> | ChainableContract | QueryCallback<Builder>): Builder;
|
121 | }
|
122 | interface WhereJsonPath<Builder extends ChainableContract> {
|
123 | (column: string, jsonPath: string, value: string | number | boolean | string[] | number[] | boolean[] | Record<string, any> | ChainableContract | QueryCallback<Builder>): Builder;
|
124 | (column: string, jsonPath: string, operator: string, value: string | number | boolean | string[] | number[] | boolean[] | Record<string, any> | ChainableContract | QueryCallback<Builder>): Builder;
|
125 | }
|
126 | |
127 |
|
128 |
|
129 | interface WhereColumn<Builder extends ChainableContract> {
|
130 | |
131 |
|
132 |
|
133 | (column: string | RawQuery, comparisonColumn: string): Builder;
|
134 | (column: string | RawQuery, operator: string, comparisonColumn: string): Builder;
|
135 | }
|
136 | |
137 |
|
138 |
|
139 | interface WhereIn<Builder extends ChainableContract> {
|
140 | |
141 |
|
142 |
|
143 | (K: string | RawQuery, value: StrictValues[]): Builder;
|
144 | |
145 |
|
146 |
|
147 | (K: string[], value: StrictValues[][]): Builder;
|
148 | |
149 |
|
150 |
|
151 |
|
152 | (k: string | RawQuery, subquery: ChainableContract | QueryCallback<Builder> | RawBuilderContract | RawQuery): Builder;
|
153 | |
154 |
|
155 |
|
156 | (k: string[], subquery: ChainableContract | RawBuilderContract | RawQuery): Builder;
|
157 | }
|
158 | |
159 |
|
160 |
|
161 | interface WhereNull<Builder extends ChainableContract> {
|
162 | (key: string | RawQuery): Builder;
|
163 | }
|
164 | |
165 |
|
166 |
|
167 | interface WhereExists<Builder extends ChainableContract> {
|
168 | (callback: QueryCallback<Builder> | ChainableContract | RawBuilderContract | RawQuery): Builder;
|
169 | }
|
170 | |
171 |
|
172 |
|
173 | interface WhereBetween<Builder extends ChainableContract> {
|
174 | |
175 |
|
176 |
|
177 | (key: string | RawQuery, value: [StrictValues | ChainableContract, StrictValues | ChainableContract]): Builder;
|
178 | }
|
179 | |
180 |
|
181 |
|
182 | interface Join<Builder extends ChainableContract> {
|
183 | |
184 |
|
185 |
|
186 |
|
187 | (table: string, primaryColumn: string, secondaryColumn: string): Builder;
|
188 | |
189 |
|
190 |
|
191 |
|
192 | (table: string, primaryColumn: string, raw: RawQuery): Builder;
|
193 | |
194 |
|
195 |
|
196 |
|
197 | (table: string, primaryColumn: string, operator: string, secondaryColumn: string): Builder;
|
198 | |
199 |
|
200 |
|
201 |
|
202 | (table: string, callback: Knex.JoinCallback): Builder;
|
203 | }
|
204 | |
205 |
|
206 |
|
207 | interface Distinct<Builder extends ChainableContract> {
|
208 | (columns: string[]): Builder;
|
209 | (...columns: string[]): Builder;
|
210 | (column: '*'): Builder;
|
211 | }
|
212 | |
213 |
|
214 |
|
215 |
|
216 | interface GroupBy<Builder extends ChainableContract> extends Distinct<Builder> {
|
217 | }
|
218 | |
219 |
|
220 |
|
221 |
|
222 | interface Aggregate<Builder extends ChainableContract> {
|
223 | |
224 |
|
225 |
|
226 | (column: OneOrMany<ValueWithSubQueries<string>>, alias?: string): Builder;
|
227 | |
228 |
|
229 |
|
230 | (columns: Dictionary<OneOrMany<ValueWithSubQueries<string>>, string>): Builder;
|
231 | }
|
232 | |
233 |
|
234 |
|
235 | interface OrderBy<Builder extends ChainableContract> {
|
236 | |
237 |
|
238 |
|
239 | (column: string | ChainableContract | RawBuilderContract | RawQuery, direction?: 'asc' | 'desc'): Builder;
|
240 | |
241 |
|
242 |
|
243 | (columns: string[]): Builder;
|
244 | |
245 |
|
246 |
|
247 | (columns: {
|
248 | column: string | ChainableContract | RawBuilderContract | RawQuery;
|
249 | order?: 'asc' | 'desc';
|
250 | }[]): Builder;
|
251 | }
|
252 | |
253 |
|
254 |
|
255 | interface Union<Builder extends ChainableContract> {
|
256 | (callback: OneOrMany<QueryCallback<Builder>>, wrap?: boolean): Builder;
|
257 | (subquery: OneOrMany<ChainableContract | RawQuery>, wrap?: boolean): Builder;
|
258 | }
|
259 | |
260 |
|
261 |
|
262 | interface UnionAll<Builder extends ChainableContract> extends Union<Builder> {
|
263 | }
|
264 | |
265 |
|
266 |
|
267 | interface Intersect<Builder extends ChainableContract> extends Union<Builder> {
|
268 | }
|
269 | |
270 |
|
271 |
|
272 | interface Having<Builder extends ChainableContract> {
|
273 | |
274 |
|
275 |
|
276 | (callback: QueryCallback<Builder> | RawBuilderContract | RawQuery): Builder;
|
277 | |
278 |
|
279 |
|
280 | (key: string | RawQuery, operator: string, value: StrictValues | ChainableContract | RawBuilderContract | RawQuery): Builder;
|
281 | }
|
282 | |
283 |
|
284 |
|
285 | interface HavingIn<Builder extends ChainableContract> {
|
286 | |
287 |
|
288 |
|
289 |
|
290 | (key: string | RawQuery, value: (StrictValues | ChainableContract | RawBuilderContract | RawQuery)[]): Builder;
|
291 | |
292 |
|
293 |
|
294 | (key: string | RawQuery, callback: QueryCallback<Builder>): Builder;
|
295 | }
|
296 | |
297 |
|
298 |
|
299 | interface HavingNull<Builder extends ChainableContract> extends WhereNull<Builder> {
|
300 | }
|
301 | |
302 |
|
303 |
|
304 | interface HavingExists<Builder extends ChainableContract> {
|
305 | |
306 |
|
307 |
|
308 | (callback: QueryCallback<Builder> | ChainableContract): Builder;
|
309 | }
|
310 | |
311 |
|
312 |
|
313 | interface HavingBetween<Builder extends ChainableContract> extends WhereBetween<Builder> {
|
314 | }
|
315 | |
316 |
|
317 |
|
318 | interface With<Builder extends ChainableContract> {
|
319 | (alias: string, query: RawQuery | ChainableContract | QueryCallback<Builder>, columns?: string[]): Builder;
|
320 | }
|
321 | |
322 |
|
323 |
|
324 | interface FromTable<Builder extends ChainableContract> {
|
325 | (table: string | Dictionary<string, string> | QueryCallback<Builder> | ChainableContract): Builder;
|
326 | }
|
327 | |
328 |
|
329 |
|
330 | interface Returning<Builder> {
|
331 | (column: OneOrMany<string>): Builder;
|
332 | }
|
333 | |
334 |
|
335 |
|
336 | interface Update<Builder extends ChainableContract> {
|
337 | |
338 |
|
339 |
|
340 |
|
341 | (values: Dictionary<any, string>, returning?: OneOrMany<string>): Builder;
|
342 | |
343 |
|
344 |
|
345 | (column: string, value: any, returning?: OneOrMany<string>): Builder;
|
346 | }
|
347 | |
348 |
|
349 |
|
350 |
|
351 | interface Counter<Builder extends ChainableContract> {
|
352 | (column: string, counter?: number): Builder;
|
353 | (values: Dictionary<number, string>): Builder;
|
354 | }
|
355 | |
356 |
|
357 |
|
358 | interface Insert<Builder extends InsertQueryBuilderContract> {
|
359 | (values: Dictionary<any, string>): Builder;
|
360 | }
|
361 | |
362 |
|
363 |
|
364 | interface MultiInsert<Builder extends InsertQueryBuilderContract> {
|
365 | (values: Dictionary<any, string>[]): Builder;
|
366 | }
|
367 | |
368 |
|
369 |
|
370 |
|
371 |
|
372 | interface ChainableContract {
|
373 | knexQuery: Knex.QueryBuilder;
|
374 | columns: (string | Knex.QueryBuilder | Knex.RawQueryBuilder)[];
|
375 | subQueryAlias?: string;
|
376 | hasAggregates: boolean;
|
377 | hasGroupBy: boolean;
|
378 | hasUnion: boolean;
|
379 | keysResolver?: (columnName: string) => string;
|
380 | from: FromTable<this>;
|
381 | select: DatabaseQueryBuilderSelect<this>;
|
382 | wrapExisting(): this;
|
383 | where: Where<this>;
|
384 | orWhere: Where<this>;
|
385 | andWhere: Where<this>;
|
386 | whereNot: Where<this>;
|
387 | orWhereNot: Where<this>;
|
388 | andWhereNot: Where<this>;
|
389 | whereColumn: WhereColumn<this>;
|
390 | orWhereColumn: WhereColumn<this>;
|
391 | andWhereColumn: WhereColumn<this>;
|
392 | whereNotColumn: WhereColumn<this>;
|
393 | orWhereNotColumn: WhereColumn<this>;
|
394 | andWhereNotColumn: WhereColumn<this>;
|
395 | whereIn: WhereIn<this>;
|
396 | orWhereIn: WhereIn<this>;
|
397 | andWhereIn: WhereIn<this>;
|
398 | whereNotIn: WhereIn<this>;
|
399 | orWhereNotIn: WhereIn<this>;
|
400 | andWhereNotIn: WhereIn<this>;
|
401 | whereNull: WhereNull<this>;
|
402 | orWhereNull: WhereNull<this>;
|
403 | andWhereNull: WhereNull<this>;
|
404 | whereNotNull: WhereNull<this>;
|
405 | orWhereNotNull: WhereNull<this>;
|
406 | andWhereNotNull: WhereNull<this>;
|
407 | whereExists: WhereExists<this>;
|
408 | orWhereExists: WhereExists<this>;
|
409 | andWhereExists: WhereExists<this>;
|
410 | whereNotExists: WhereExists<this>;
|
411 | orWhereNotExists: WhereExists<this>;
|
412 | andWhereNotExists: WhereExists<this>;
|
413 | whereBetween: WhereBetween<this>;
|
414 | orWhereBetween: WhereBetween<this>;
|
415 | andWhereBetween: WhereBetween<this>;
|
416 | whereNotBetween: WhereBetween<this>;
|
417 | orWhereNotBetween: WhereBetween<this>;
|
418 | andWhereNotBetween: WhereBetween<this>;
|
419 | whereRaw: RawQueryFn<this>;
|
420 | orWhereRaw: RawQueryFn<this>;
|
421 | andWhereRaw: RawQueryFn<this>;
|
422 | whereLike: WhereLike<this>;
|
423 | orWhereLike: WhereLike<this>;
|
424 | andWhereLike: WhereLike<this>;
|
425 | whereILike: WhereLike<this>;
|
426 | orWhereILike: WhereLike<this>;
|
427 | andWhereILike: WhereLike<this>;
|
428 | whereJson: WhereJson<this>;
|
429 | orWhereJson: WhereJson<this>;
|
430 | andWhereJson: WhereJson<this>;
|
431 | whereNotJson: WhereJson<this>;
|
432 | orWhereNotJson: WhereJson<this>;
|
433 | andWhereNotJson: WhereJson<this>;
|
434 | whereJsonSuperset: WhereJson<this>;
|
435 | orWhereJsonSuperset: WhereJson<this>;
|
436 | andWhereJsonSuperset: WhereJson<this>;
|
437 | whereNotJsonSuperset: WhereJson<this>;
|
438 | orWhereNotJsonSuperset: WhereJson<this>;
|
439 | andWhereNotJsonSuperset: WhereJson<this>;
|
440 | whereJsonSubset: WhereJson<this>;
|
441 | orWhereJsonSubset: WhereJson<this>;
|
442 | andWhereJsonSubset: WhereJson<this>;
|
443 | whereNotJsonSubset: WhereJson<this>;
|
444 | orWhereNotJsonSubset: WhereJson<this>;
|
445 | andWhereNotJsonSubset: WhereJson<this>;
|
446 | whereJsonPath: WhereJsonPath<this>;
|
447 | orWhereJsonPath: WhereJsonPath<this>;
|
448 | andWhereJsonPath: WhereJsonPath<this>;
|
449 | join: Join<this>;
|
450 | innerJoin: Join<this>;
|
451 | leftJoin: Join<this>;
|
452 | leftOuterJoin: Join<this>;
|
453 | rightJoin: Join<this>;
|
454 | rightOuterJoin: Join<this>;
|
455 | fullOuterJoin: Join<this>;
|
456 | crossJoin: Join<this>;
|
457 | joinRaw: RawQueryFn<this>;
|
458 | having: Having<this>;
|
459 | orHaving: Having<this>;
|
460 | andHaving: Having<this>;
|
461 | havingIn: HavingIn<this>;
|
462 | orHavingIn: HavingIn<this>;
|
463 | andHavingIn: HavingIn<this>;
|
464 | havingNotIn: HavingIn<this>;
|
465 | orHavingNotIn: HavingIn<this>;
|
466 | andHavingNotIn: HavingIn<this>;
|
467 | havingNull: HavingNull<this>;
|
468 | orHavingNull: HavingNull<this>;
|
469 | andHavingNull: HavingNull<this>;
|
470 | havingNotNull: HavingNull<this>;
|
471 | orHavingNotNull: HavingNull<this>;
|
472 | andHavingNotNull: HavingNull<this>;
|
473 | havingExists: HavingExists<this>;
|
474 | orHavingExists: HavingExists<this>;
|
475 | andHavingExists: HavingExists<this>;
|
476 | havingNotExists: HavingExists<this>;
|
477 | orHavingNotExists: HavingExists<this>;
|
478 | andHavingNotExists: HavingExists<this>;
|
479 | havingBetween: HavingBetween<this>;
|
480 | orHavingBetween: HavingBetween<this>;
|
481 | andHavingBetween: HavingBetween<this>;
|
482 | havingNotBetween: HavingBetween<this>;
|
483 | orHavingNotBetween: HavingBetween<this>;
|
484 | andHavingNotBetween: HavingBetween<this>;
|
485 | havingRaw: RawQueryFn<this>;
|
486 | orHavingRaw: RawQueryFn<this>;
|
487 | andHavingRaw: RawQueryFn<this>;
|
488 | distinct: Distinct<this>;
|
489 | distinctOn: Distinct<this>;
|
490 | groupBy: GroupBy<this>;
|
491 | groupByRaw: RawQueryFn<this>;
|
492 | orderBy: OrderBy<this>;
|
493 | orderByRaw: RawQueryFn<this>;
|
494 | union: Union<this>;
|
495 | unionAll: UnionAll<this>;
|
496 | intersect: Intersect<this>;
|
497 | with: With<this>;
|
498 | withRecursive: With<this>;
|
499 | withMaterialized: With<this>;
|
500 | withNotMaterialized: With<this>;
|
501 | withSchema(schema: string): this;
|
502 | as(name: string): this;
|
503 | offset(offset: number): this;
|
504 | limit(limit: number): this;
|
505 | clearSelect(): this;
|
506 | clearWhere(): this;
|
507 | clearOrder(): this;
|
508 | clearHaving(): this;
|
509 | clearLimit(): this;
|
510 | clearOffset(): this;
|
511 | forUpdate(...tableNames: string[]): this;
|
512 | forShare(...tableNames: string[]): this;
|
513 | skipLocked(): this;
|
514 | noWait(): this;
|
515 | |
516 |
|
517 |
|
518 | if(condition: any, matchCallback: (query: this) => any, noMatchCallback?: (query: this) => any): this;
|
519 | |
520 |
|
521 |
|
522 | unless(condition: any, matchCallback: (query: this) => any, noMatchCallback?: (query: this) => any): this;
|
523 | |
524 |
|
525 |
|
526 | match(...blocks: ([condition: any, callback: (query: this) => any] | ((query: this) => any))[]): this;
|
527 | }
|
528 | /**
|
529 | * Shape of the raw query that can also be passed as a value to
|
530 | * other queries
|
531 | */
|
532 | interface RawQueryBuilderContract<Result = any> extends ExcutableQueryBuilderContract<Result> {
|
533 | knexQuery: Knex.Raw;
|
534 | client: QueryClientContract;
|
535 | wrap(before: string, after: string): this;
|
536 | }
|
537 | /**
|
538 | * Reference builder
|
539 | */
|
540 | interface ReferenceBuilderContract {
|
541 | withSchema(name: string): this;
|
542 | as(name: string): this;
|
543 | toKnex(client: Knex.Client): Knex.Ref<string, any>;
|
544 | }
|
545 | /**
|
546 | * Static raw builder
|
547 | */
|
548 | interface RawBuilderContract {
|
549 | wrap(before: string, after: string): this;
|
550 | toKnex(client: Knex.Client): Knex.Raw;
|
551 | }
|
552 | /**
|
553 | * The keys for the simple paginator meta
|
554 | * data
|
555 | */
|
556 | type SimplePaginatorMetaKeys = {
|
557 | total: string;
|
558 | perPage: string;
|
559 | currentPage: string;
|
560 | lastPage: string;
|
561 | firstPage: string;
|
562 | firstPageUrl: string;
|
563 | lastPageUrl: string;
|
564 | nextPageUrl: string;
|
565 | previousPageUrl: string;
|
566 | };
|
567 | /**
|
568 | * Shape of the simple paginator that works with offset and limit
|
569 | */
|
570 | interface SimplePaginatorContract<Result> extends Array<Result> {
|
571 | all(): Result[];
|
572 | readonly firstPage: number;
|
573 | readonly perPage: number;
|
574 | readonly currentPage: number;
|
575 | readonly lastPage: number;
|
576 | readonly hasPages: boolean;
|
577 | readonly hasMorePages: boolean;
|
578 | readonly isEmpty: boolean;
|
579 | readonly total: number;
|
580 | readonly hasTotal: boolean;
|
581 | namingStrategy: {
|
582 | paginationMetaKeys(): SimplePaginatorMetaKeys;
|
583 | };
|
584 | baseUrl(url: string): this;
|
585 | queryString(values: {
|
586 | [key: string]: any;
|
587 | }): this;
|
588 | getUrl(page: number): string;
|
589 | getMeta(): any;
|
590 | getNextPageUrl(): string | null;
|
591 | getPreviousPageUrl(): string | null;
|
592 | getUrlsForRange(start: number, end: number): {
|
593 | url: string;
|
594 | page: number;
|
595 | isActive: boolean;
|
596 | }[];
|
597 | toJSON(): {
|
598 | meta: any;
|
599 | data: Result[];
|
600 | };
|
601 | }
|
602 | /**
|
603 | * Database query builder exposes the API to construct SQL query using fluent
|
604 | * chainable API
|
605 | */
|
606 | interface DatabaseQueryBuilderContract<Result = Dictionary<any, string>> extends ChainableContract, ExcutableQueryBuilderContract<Result[]> {
|
607 | client: QueryClientContract;
|
608 | returning: Returning<this>;
|
609 | /**
|
610 | * Clone current query
|
611 | */
|
612 | clone<ClonedResult = Result>(): DatabaseQueryBuilderContract<ClonedResult>;
|
613 | /**
|
614 | * Execute and get first result
|
615 | */
|
616 | first(): Promise<Result | null>;
|
617 | /**
|
618 | * Execute and get first result or fail
|
619 | */
|
620 | firstOrFail(): Promise<Result>;
|
621 | /**
|
622 | * Perform delete operation
|
623 | */
|
624 | del(returning?: OneOrMany<string>): this;
|
625 | delete(returning?: OneOrMany<string>): this;
|
626 | /**
|
627 | * A shorthand to define limit and offset based upon the
|
628 | * current page
|
629 | */
|
630 | forPage(page: number, perPage?: number): this;
|
631 | /**
|
632 | * Execute query with pagination
|
633 | */
|
634 | paginate(page: number, perPage?: number): Promise<SimplePaginatorContract<Result>>;
|
635 | /**
|
636 | * Mutations (update and increment can be one query aswell)
|
637 | */
|
638 | update: Update<this>;
|
639 | increment: Counter<this>;
|
640 | decrement: Counter<this>;
|
641 | /**
|
642 | * Aggregates
|
643 | */
|
644 | count: Aggregate<this>;
|
645 | countDistinct: Aggregate<this>;
|
646 | min: Aggregate<this>;
|
647 | max: Aggregate<this>;
|
648 | sum: Aggregate<this>;
|
649 | sumDistinct: Aggregate<this>;
|
650 | avg: Aggregate<this>;
|
651 | avgDistinct: Aggregate<this>;
|
652 | /**
|
653 | * Executes the callback when dialect matches one of the mentioned
|
654 | * dialects
|
655 | */
|
656 | ifDialect(dialect: DialectContract['name'] | DialectContract['name'][], matchCallback: (query: this) => any, noMatchCallback?: (query: this) => any): this;
|
657 | /**
|
658 | * Executes the callback when dialect matches doesn't all the mentioned
|
659 | * dialects
|
660 | */
|
661 | unlessDialect(dialect: DialectContract['name'] | DialectContract['name'][], matchCallback: (query: this) => any, noMatchCallback?: (query: this) => any): this;
|
662 | }
|
663 | /**
|
664 | * Insert query builder to perform database inserts.
|
665 | */
|
666 | interface InsertQueryBuilderContract<Result = any> extends ExcutableQueryBuilderContract<Result> {
|
667 | knexQuery: Knex.QueryBuilder;
|
668 | client: QueryClientContract;
|
669 | /**
|
670 | * Table for the insert query
|
671 | */
|
672 | table(table: string): this;
|
673 | withSchema(schema: string): this;
|
674 | /**
|
675 | * Define returning columns
|
676 | */
|
677 | returning: Returning<this>;
|
678 | /**
|
679 | * Inserting a single record.
|
680 | */
|
681 | insert: Insert<this>;
|
682 | /**
|
683 | * Inserting multiple columns at once
|
684 | */
|
685 | multiInsert: MultiInsert<this>;
|
686 | }
|
687 | /**
|
688 | * A executable query builder will always have these methods on it.
|
689 | */
|
690 | interface ExcutableQueryBuilderContract<Result> extends Promise<Result> {
|
691 | debug(debug: boolean): this;
|
692 | timeout(time: number, options?: {
|
693 | cancel: boolean;
|
694 | }): this;
|
695 | useTransaction(trx: TransactionClientContract): this;
|
696 | reporterData(data: any): this;
|
697 | toQuery(): string;
|
698 | exec(): Promise<Result>;
|
699 | toSQL(): Knex.Sql;
|
700 | }
|
701 | }
|
702 |
|
\ | No newline at end of file |