1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import tarn = require('tarn');
|
10 | import events = require('events');
|
11 | import stream = require('stream');
|
12 | import ResultTypes = require('./result');
|
13 |
|
14 | import { Tables } from './tables';
|
15 |
|
16 | import { Stream } from 'stream';
|
17 | import { ConnectionOptions } from 'tls';
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | type SafePartial<T> = Partial<AnyOrUnknownToOther<T, {}>>;
|
26 |
|
27 | type MaybeArray<T> = T | T[];
|
28 |
|
29 | type StrKey<T> = string & keyof T;
|
30 |
|
31 |
|
32 | type UnknownToAny<T> = unknown extends T ? any : T;
|
33 | type CurlyCurlyToAny<T> = T extends unknown
|
34 | ? (<U>() => U extends T ? 0 : 1) extends <U>() => U extends {} ? 0 : 1
|
35 | ? any
|
36 | : T
|
37 | : never;
|
38 | type UnknownOrCurlyCurlyToAny<T> = [UnknownToAny<T> | CurlyCurlyToAny<T>][0];
|
39 | type AnyToUnknown<T> = unknown extends T ? unknown : T;
|
40 | type AnyOrUnknownToOther<T1, T2> = unknown extends T1 ? T2 : T1;
|
41 |
|
42 |
|
43 |
|
44 | type AugmentParams<TTarget, TParams> = TParams extends {}
|
45 | ? keyof TParams extends never
|
46 | ? TTarget
|
47 | : {} & TTarget & TParams
|
48 | : TTarget;
|
49 |
|
50 |
|
51 | type AreKeysOf<TBase, TKeys> = Boxed<TKeys> extends Boxed<keyof TBase>
|
52 | ? true
|
53 | : false;
|
54 |
|
55 |
|
56 | type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
57 | k: infer I
|
58 | ) => void
|
59 | ? I
|
60 | : never;
|
61 |
|
62 | type ComparisonOperator = '=' | '>' | '>=' | '<' | '<=' | '<>';
|
63 |
|
64 |
|
65 | type ArrayMember<T> = T extends (infer M)[] ? M : never;
|
66 |
|
67 |
|
68 | type UnwrapArrayMember<T> = T extends (infer M)[] ? M : T;
|
69 |
|
70 |
|
71 |
|
72 | interface Boxed<T> {
|
73 | _value: T;
|
74 | }
|
75 |
|
76 |
|
77 | type IncompatibleToAlt<T, TBase, TAlt> = T extends TBase ? T : TAlt;
|
78 |
|
79 | type ArrayIfAlready<T1, T2> = AnyToUnknown<T1> extends any[] ? T2[] : T2;
|
80 |
|
81 |
|
82 |
|
83 | type PartialOrAny<TBase, TKeys> = Boxed<TKeys> extends Boxed<never>
|
84 | ? {}
|
85 | : Boxed<TKeys> extends Boxed<keyof TBase>
|
86 | ? SafePick<TBase, TKeys & keyof TBase>
|
87 | : any;
|
88 |
|
89 |
|
90 |
|
91 | type MappedAliasType<TBase, TAliasMapping> = {} & {
|
92 | [K in keyof TAliasMapping]: TAliasMapping[K] extends keyof TBase
|
93 | ? TBase[TAliasMapping[K]]
|
94 | : any;
|
95 | };
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | type DeferredKeySelection<
|
102 |
|
103 |
|
104 | TBase,
|
105 |
|
106 |
|
107 | TKeys extends string,
|
108 |
|
109 |
|
110 |
|
111 | THasSelect extends true | false = false,
|
112 |
|
113 | TAliasMapping extends {} = {},
|
114 |
|
115 |
|
116 | TSingle extends boolean = false,
|
117 |
|
118 | TIntersectProps extends {} = {},
|
119 |
|
120 | TUnionProps = never
|
121 | > = {
|
122 |
|
123 |
|
124 | _base: TBase;
|
125 | _hasSelection: THasSelect;
|
126 | _keys: TKeys;
|
127 | _aliases: TAliasMapping;
|
128 | _single: TSingle;
|
129 | _intersectProps: TIntersectProps;
|
130 | _unionProps: TUnionProps;
|
131 | };
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | declare namespace DeferredKeySelection {
|
140 | type Any = DeferredKeySelection<any, any, any, any, any, any, any>;
|
141 |
|
142 |
|
143 |
|
144 | type SetBase<TSelection, TBase> = TSelection extends DeferredKeySelection<
|
145 | any,
|
146 | infer TKeys,
|
147 | infer THasSelect,
|
148 | infer TAliasMapping,
|
149 | infer TSingle,
|
150 | infer TIntersectProps,
|
151 | infer TUnionProps
|
152 | >
|
153 | ? DeferredKeySelection<
|
154 | TBase,
|
155 | TKeys,
|
156 | THasSelect,
|
157 | TAliasMapping,
|
158 | TSingle,
|
159 | TIntersectProps,
|
160 | TUnionProps
|
161 | >
|
162 | : DeferredKeySelection<TBase, never>;
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | type ReplaceBase<TSelection, TBase> =
|
171 | UnwrapArrayMember<TSelection> extends DeferredKeySelection.Any
|
172 | ? ArrayIfAlready<
|
173 | TSelection,
|
174 | DeferredKeySelection.SetBase<UnwrapArrayMember<TSelection>, TBase>
|
175 | >
|
176 | : unknown extends UnwrapArrayMember<TSelection>
|
177 | ? ArrayIfAlready<TSelection, DeferredKeySelection.SetBase<unknown, TBase>>
|
178 | : TSelection;
|
179 |
|
180 |
|
181 |
|
182 | type SetSingle<
|
183 | TSelection,
|
184 | TSingle extends boolean
|
185 | > = TSelection extends DeferredKeySelection<
|
186 | infer TBase,
|
187 | infer TKeys,
|
188 | infer THasSelect,
|
189 | infer TAliasMapping,
|
190 | any,
|
191 | infer TIntersectProps,
|
192 | infer TUnionProps
|
193 | >
|
194 | ? DeferredKeySelection<
|
195 | TBase,
|
196 | TKeys,
|
197 | THasSelect,
|
198 | TAliasMapping,
|
199 | TSingle,
|
200 | TIntersectProps,
|
201 | TUnionProps
|
202 | >
|
203 | : never;
|
204 |
|
205 | type AddKey<
|
206 | TSelection,
|
207 | TKey extends string
|
208 | > = TSelection extends DeferredKeySelection<
|
209 | infer TBase,
|
210 | infer TKeys,
|
211 | any,
|
212 | infer TAliasMapping,
|
213 | infer TSingle,
|
214 | infer TIntersectProps,
|
215 | infer TUnionProps
|
216 | >
|
217 | ? DeferredKeySelection<
|
218 | TBase,
|
219 | TKeys | TKey,
|
220 | true,
|
221 | TAliasMapping,
|
222 | TSingle,
|
223 | TIntersectProps,
|
224 | TUnionProps
|
225 | >
|
226 | : DeferredKeySelection<unknown, TKey, true>;
|
227 |
|
228 | type AddAliases<
|
229 | TSelection,
|
230 | T extends {}
|
231 | > = TSelection extends DeferredKeySelection<
|
232 | infer TBase,
|
233 | infer TKeys,
|
234 | infer THasSelect,
|
235 | infer TAliasMapping,
|
236 | infer TSingle,
|
237 | infer TIntersectProps,
|
238 | infer TUnionProps
|
239 | >
|
240 | ? DeferredKeySelection<
|
241 | TBase,
|
242 | TKeys,
|
243 | THasSelect,
|
244 | TAliasMapping & T,
|
245 | TSingle,
|
246 | TIntersectProps,
|
247 | TUnionProps
|
248 | >
|
249 | : DeferredKeySelection<unknown, never, false, T>;
|
250 |
|
251 | type AddUnionMember<TSelection, T> = TSelection extends DeferredKeySelection<
|
252 | infer TBase,
|
253 | infer TKeys,
|
254 | infer THasSelect,
|
255 | infer TAliasMapping,
|
256 | infer TSingle,
|
257 | infer TIntersectProps,
|
258 | infer TUnionProps
|
259 | >
|
260 | ? DeferredKeySelection<
|
261 | TBase,
|
262 | TKeys,
|
263 | THasSelect,
|
264 | TAliasMapping,
|
265 | TSingle,
|
266 | TIntersectProps,
|
267 | TUnionProps | T
|
268 | >
|
269 | : DeferredKeySelection<TSelection, never, false, {}, false, {}, T>;
|
270 |
|
271 |
|
272 |
|
273 | type Augment<
|
274 | T,
|
275 | TBase,
|
276 | TKey extends string,
|
277 | TAliasMapping extends {} = {}
|
278 | > = AddAliases<AddKey<SetBase<T, TBase>, TKey>, TAliasMapping>;
|
279 |
|
280 |
|
281 | type ResolveOne<TSelection> = TSelection extends DeferredKeySelection<
|
282 | infer TBase,
|
283 | infer TKeys,
|
284 | infer THasSelect,
|
285 | infer TAliasMapping,
|
286 | infer TSingle,
|
287 | infer TIntersectProps,
|
288 | infer TUnionProps
|
289 | >
|
290 | ? UnknownOrCurlyCurlyToAny<
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 | | AugmentParams<
|
297 | AnyToUnknown<TBase> extends {}
|
298 | ?
|
299 |
|
300 | TSingle extends true
|
301 | ? TKeys extends keyof TBase
|
302 | ? TBase[TKeys]
|
303 | : any
|
304 | : AugmentParams<
|
305 | true extends THasSelect
|
306 | ? PartialOrAny<TBase, TKeys>
|
307 | : TBase,
|
308 | MappedAliasType<TBase, TAliasMapping>
|
309 | >
|
310 | : unknown,
|
311 | TIntersectProps
|
312 | >
|
313 | | TUnionProps
|
314 | >
|
315 | : TSelection;
|
316 |
|
317 | type Resolve<TSelection> = TSelection extends DeferredKeySelection.Any
|
318 | ? Knex.ResolveTableType<ResolveOne<TSelection>>
|
319 | : TSelection extends DeferredKeySelection.Any[]
|
320 | ? Knex.ResolveTableType<ResolveOne<TSelection[0]>>[]
|
321 | : TSelection extends (infer I)[]
|
322 | ? UnknownOrCurlyCurlyToAny<Knex.ResolveTableType<I>>[]
|
323 | : UnknownOrCurlyCurlyToAny<Knex.ResolveTableType<TSelection>>;
|
324 | }
|
325 |
|
326 | type AggregationQueryResult<
|
327 | TResult,
|
328 | TIntersectProps2 extends {}
|
329 | > = ArrayIfAlready<
|
330 | TResult,
|
331 | UnwrapArrayMember<TResult> extends DeferredKeySelection<
|
332 | infer TBase,
|
333 | infer TKeys,
|
334 | infer THasSelect,
|
335 | infer TAliasMapping,
|
336 | infer TSingle,
|
337 | infer TIntersectProps,
|
338 | infer TUnionProps
|
339 | >
|
340 | ? true extends THasSelect
|
341 | ? DeferredKeySelection<
|
342 | TBase,
|
343 | TKeys,
|
344 | THasSelect,
|
345 | TAliasMapping,
|
346 | TSingle,
|
347 | TIntersectProps & TIntersectProps2,
|
348 | TUnionProps
|
349 | >
|
350 | : DeferredKeySelection<{}, never, true, {}, false, TIntersectProps2>
|
351 | : TIntersectProps2
|
352 | >;
|
353 |
|
354 |
|
355 |
|
356 | type ResolveResult<S> = DeferredKeySelection.Resolve<S>;
|
357 |
|
358 |
|
359 |
|
360 | type Callback = Function;
|
361 | type Client = Function;
|
362 |
|
363 | type Dict<T = any> = { [k: string]: T };
|
364 |
|
365 | type SafePick<T, K extends keyof T> = T extends {} ? Pick<T, K> : any;
|
366 |
|
367 | type TableOptions = PgTableOptions;
|
368 |
|
369 | interface PgTableOptions {
|
370 | only?: boolean;
|
371 | }
|
372 |
|
373 | interface DMLOptions {
|
374 | includeTriggerModifications?: boolean;
|
375 | }
|
376 |
|
377 | interface Knex<TRecord extends {} = any, TResult = any[]>
|
378 | extends Knex.QueryInterface<TRecord, TResult>,
|
379 | events.EventEmitter {
|
380 | <TTable extends Knex.TableNames>(
|
381 | tableName: TTable,
|
382 | options?: TableOptions
|
383 | ): Knex.QueryBuilder<
|
384 | Knex.TableType<TTable>,
|
385 | DeferredKeySelection<Knex.ResolveTableType<Knex.TableType<TTable>>, never>[]
|
386 | >;
|
387 | <
|
388 | TRecord2 extends {} = TRecord,
|
389 | TResult2 = DeferredKeySelection<TRecord2, never>[]
|
390 | >(
|
391 | tableName?: Knex.TableDescriptor | Knex.AliasDict,
|
392 | options?: TableOptions
|
393 | ): Knex.QueryBuilder<TRecord2, TResult2>;
|
394 | VERSION: string;
|
395 | __knex__: string;
|
396 |
|
397 | raw: Knex.RawBuilder<TRecord>;
|
398 |
|
399 | transactionProvider(
|
400 | config?: Knex.TransactionConfig
|
401 | ): Knex.TransactionProvider;
|
402 | transaction(config?: Knex.TransactionConfig): Promise<Knex.Transaction>;
|
403 | transaction(
|
404 | transactionScope?: null,
|
405 | config?: Knex.TransactionConfig
|
406 | ): Promise<Knex.Transaction>;
|
407 | transaction<T>(
|
408 | transactionScope: (trx: Knex.Transaction) => Promise<T> | void,
|
409 | config?: Knex.TransactionConfig
|
410 | ): Promise<T>;
|
411 | initialize(config?: Knex.Config): void;
|
412 | destroy(callback: Function): void;
|
413 | destroy(): Promise<void>;
|
414 |
|
415 | batchInsert<TRecord2 extends {} = TRecord, TResult2 = number[]>(
|
416 | tableName: Knex.TableDescriptor,
|
417 | data: TRecord2 extends Knex.CompositeTableType<unknown>
|
418 | ? ReadonlyArray<Knex.ResolveTableType<TRecord2, 'insert'>>
|
419 | : ReadonlyArray<Knex.DbRecordArr<TRecord2>>,
|
420 | chunkSize?: number
|
421 | ): Knex.BatchInsertBuilder<TRecord2, TResult2>;
|
422 |
|
423 | schema: Knex.SchemaBuilder;
|
424 | queryBuilder<
|
425 | TRecord2 extends {} = TRecord,
|
426 | TResult2 = TResult
|
427 | >(): Knex.QueryBuilder<TRecord2, TResult2>;
|
428 |
|
429 | client: any;
|
430 | migrate: Knex.Migrator;
|
431 | seed: Knex.Seeder;
|
432 | fn: Knex.FunctionHelper;
|
433 | ref: Knex.RefBuilder;
|
434 | userParams: Record<string, any>;
|
435 | withUserParams(params: Record<string, any>): Knex;
|
436 | isTransaction?: boolean;
|
437 | }
|
438 |
|
439 | declare function knex<TRecord extends {} = any, TResult = unknown[]>(
|
440 | config: Knex.Config | string
|
441 | ): Knex<TRecord, TResult>;
|
442 |
|
443 | declare namespace knex {
|
444 | export { knex, knex as default, Knex };
|
445 | export class QueryBuilder {
|
446 | static extend(
|
447 | methodName: string,
|
448 | fn: <TRecord extends {} = any, TResult extends {} = unknown[]>(
|
449 | this: Knex.QueryBuilder<TRecord, TResult>,
|
450 | ...args: any[]
|
451 | ) =>
|
452 | | Knex.QueryBuilder<TRecord, TResult>
|
453 | | Promise<
|
454 | | Knex.QueryBuilder<TRecord | TResult>
|
455 | | DeferredKeySelection.Resolve<TResult>
|
456 | >
|
457 | ): void;
|
458 | }
|
459 |
|
460 | export class TableBuilder {
|
461 | static extend<T = Knex.TableBuilder, B = Knex.TableBuilder>(
|
462 | methodName: string,
|
463 | fn: (this: T, ...args: any[]) => B
|
464 | ): void;
|
465 | }
|
466 | export class ViewBuilder {
|
467 | static extend<T = Knex.ViewBuilder, B = Knex.ViewBuilder>(
|
468 | methodName: string,
|
469 | fn: (this: T, ...args: any[]) => B
|
470 | ): void;
|
471 | }
|
472 | export class SchemaBuilder {
|
473 | static extend<T = Knex.SchemaBuilder, B = Knex.SchemaBuilder>(
|
474 | methodName: string,
|
475 | fn: (this: T, ...args: any[]) => B
|
476 | ): void;
|
477 | }
|
478 | export class ColumnBuilder {
|
479 | static extend<T = Knex.ColumnBuilder, B = Knex.ColumnBuilder>(
|
480 | methodName: string,
|
481 | fn: (this: T, ...args: any[]) => B
|
482 | ): void;
|
483 | }
|
484 |
|
485 | export class KnexTimeoutError extends Error {}
|
486 |
|
487 | export const Client: typeof Knex.Client;
|
488 | }
|
489 |
|
490 | declare namespace Knex {
|
491 |
|
492 |
|
493 |
|
494 |
|
495 | type Value =
|
496 | | string
|
497 | | number
|
498 | | boolean
|
499 | | null
|
500 | | Date
|
501 | | Array<string>
|
502 | | Array<number>
|
503 | | Array<Date>
|
504 | | Array<boolean>
|
505 | | Buffer
|
506 | | object
|
507 | | Knex.Raw;
|
508 |
|
509 | interface ValueDict extends Dict<Value | Knex.QueryBuilder> {}
|
510 | interface AliasDict extends Dict<string> {}
|
511 |
|
512 | type ColumnDescriptor<TRecord extends {}, TResult> =
|
513 | | string
|
514 | | Knex.Raw
|
515 | | Knex.QueryBuilder<TRecord, TResult>
|
516 | | Dict<string>;
|
517 |
|
518 | type InferrableColumnDescriptor<TRecord extends {}> =
|
519 | | keyof TRecord
|
520 | | Knex.Ref<any, any>
|
521 | | Dict<keyof TRecord>;
|
522 |
|
523 | type TableDescriptor = string | Knex.Raw | Knex.QueryBuilder;
|
524 |
|
525 | type Lookup<
|
526 | TRegistry extends {},
|
527 | TKey extends string,
|
528 | TDefault = never
|
529 | > = TKey extends keyof TRegistry ? TRegistry[TKey] : TDefault;
|
530 |
|
531 | type MaybeRawColumn<TColumn> = TColumn | Raw<TColumn>;
|
532 |
|
533 | type MaybeRawRecord<TRecord> = {
|
534 | [K in keyof TRecord]: MaybeRawColumn<TRecord[K]>;
|
535 | };
|
536 |
|
537 | type DbColumn<TColumn> = Readonly<MaybeRawColumn<TColumn>>;
|
538 |
|
539 | type DbRecord<TRecord> = Readonly<SafePartial<MaybeRawRecord<TRecord>>>;
|
540 |
|
541 | type DbRecordArr<TRecord> = Readonly<MaybeArray<DbRecord<TRecord>>>;
|
542 |
|
543 | export type CompositeTableType<
|
544 | TBase,
|
545 | TInsert = TBase,
|
546 | TUpdate = Partial<TInsert>,
|
547 | TUpsert = Partial<TInsert>
|
548 | > = {
|
549 | base: TBase;
|
550 | insert: TInsert;
|
551 | update: TUpdate;
|
552 | upsert: TUpsert;
|
553 | };
|
554 |
|
555 | type TableNames = keyof Tables;
|
556 |
|
557 | type TableInterfaceScope = keyof CompositeTableType<unknown>;
|
558 |
|
559 | type TableType<TTable extends keyof Tables> = Tables[TTable];
|
560 |
|
561 | type ResolveTableType<
|
562 | TCompositeTableType,
|
563 | TScope extends TableInterfaceScope = 'base'
|
564 | > = TCompositeTableType extends CompositeTableType<{}>
|
565 | ? TCompositeTableType[TScope]
|
566 | : TCompositeTableType;
|
567 |
|
568 | interface OnConflictQueryBuilder<TRecord extends {}, TResult> {
|
569 | ignore(): QueryBuilder<TRecord, TResult>;
|
570 | merge(
|
571 | mergeColumns?: (keyof ResolveTableType<TRecord, 'update'>)[]
|
572 | ): QueryBuilder<TRecord, TResult>;
|
573 | merge(
|
574 | data?: Extract<DbRecord<ResolveTableType<TRecord, 'update'>>, object>
|
575 | ): QueryBuilder<TRecord, TResult>;
|
576 | }
|
577 |
|
578 |
|
579 |
|
580 |
|
581 | type ClearStatements =
|
582 | | 'with'
|
583 | | 'select'
|
584 | | 'columns'
|
585 | | 'hintComments'
|
586 | | 'where'
|
587 | | 'union'
|
588 | | 'using'
|
589 | | 'join'
|
590 | | 'group'
|
591 | | 'order'
|
592 | | 'having'
|
593 | | 'limit'
|
594 | | 'offset'
|
595 | | 'counter'
|
596 | | 'counters';
|
597 |
|
598 | interface QueryInterface<TRecord extends {} = any, TResult = any> {
|
599 | select: Select<TRecord, TResult>;
|
600 | as: As<TRecord, TResult>;
|
601 | columns: Select<TRecord, TResult>;
|
602 | column: Select<TRecord, TResult>;
|
603 | comment: Comment<TRecord, TResult>;
|
604 | hintComment: HintComment<TRecord, TResult>;
|
605 | from: Table<TRecord, TResult>;
|
606 | fromRaw: Table<TRecord, TResult>;
|
607 | into: Table<TRecord, TResult>;
|
608 | table: Table<TRecord, TResult>;
|
609 | distinct: Distinct<TRecord, TResult>;
|
610 | distinctOn: DistinctOn<TRecord, TResult>;
|
611 |
|
612 |
|
613 | join: Join<TRecord, TResult>;
|
614 | joinRaw: JoinRaw<TRecord, TResult>;
|
615 | innerJoin: Join<TRecord, TResult>;
|
616 | leftJoin: Join<TRecord, TResult>;
|
617 | leftOuterJoin: Join<TRecord, TResult>;
|
618 | rightJoin: Join<TRecord, TResult>;
|
619 | rightOuterJoin: Join<TRecord, TResult>;
|
620 | outerJoin: Join<TRecord, TResult>;
|
621 | fullOuterJoin: Join<TRecord, TResult>;
|
622 | crossJoin: Join<TRecord, TResult>;
|
623 |
|
624 |
|
625 | jsonExtract: JsonExtract<TRecord, TResult>;
|
626 | jsonSet: JsonSet<TRecord, TResult>;
|
627 | jsonInsert: JsonInsert<TRecord, TResult>;
|
628 | jsonRemove: JsonRemove<TRecord, TResult>;
|
629 |
|
630 |
|
631 | using: Using<TRecord, TResult>;
|
632 |
|
633 |
|
634 | with: With<TRecord, TResult>;
|
635 | withMaterialized: With<TRecord, TResult>;
|
636 | withNotMaterialized: With<TRecord, TResult>;
|
637 | withRecursive: With<TRecord, TResult>;
|
638 | withRaw: WithRaw<TRecord, TResult>;
|
639 | withSchema: WithSchema<TRecord, TResult>;
|
640 | withWrapped: WithWrapped<TRecord, TResult>;
|
641 |
|
642 |
|
643 | where: Where<TRecord, TResult>;
|
644 | andWhere: Where<TRecord, TResult>;
|
645 | orWhere: Where<TRecord, TResult>;
|
646 | whereNot: Where<TRecord, TResult>;
|
647 | andWhereNot: Where<TRecord, TResult>;
|
648 | orWhereNot: Where<TRecord, TResult>;
|
649 | whereRaw: WhereRaw<TRecord, TResult>;
|
650 | orWhereRaw: WhereRaw<TRecord, TResult>;
|
651 | andWhereRaw: WhereRaw<TRecord, TResult>;
|
652 | whereWrapped: WhereWrapped<TRecord, TResult>;
|
653 | havingWrapped: WhereWrapped<TRecord, TResult>;
|
654 | whereExists: WhereExists<TRecord, TResult>;
|
655 | orWhereExists: WhereExists<TRecord, TResult>;
|
656 | whereNotExists: WhereExists<TRecord, TResult>;
|
657 | orWhereNotExists: WhereExists<TRecord, TResult>;
|
658 | whereIn: WhereIn<TRecord, TResult>;
|
659 | orWhereIn: WhereIn<TRecord, TResult>;
|
660 | whereNotIn: WhereIn<TRecord, TResult>;
|
661 | orWhereNotIn: WhereIn<TRecord, TResult>;
|
662 | whereLike: Where<TRecord, TResult>;
|
663 | andWhereLike: Where<TRecord, TResult>;
|
664 | orWhereLike: Where<TRecord, TResult>;
|
665 | whereILike: Where<TRecord, TResult>;
|
666 | andWhereILike: Where<TRecord, TResult>;
|
667 | orWhereILike: Where<TRecord, TResult>;
|
668 | whereNull: WhereNull<TRecord, TResult>;
|
669 | orWhereNull: WhereNull<TRecord, TResult>;
|
670 | whereNotNull: WhereNull<TRecord, TResult>;
|
671 | orWhereNotNull: WhereNull<TRecord, TResult>;
|
672 | whereBetween: WhereBetween<TRecord, TResult>;
|
673 | orWhereBetween: WhereBetween<TRecord, TResult>;
|
674 | andWhereBetween: WhereBetween<TRecord, TResult>;
|
675 | whereNotBetween: WhereBetween<TRecord, TResult>;
|
676 | orWhereNotBetween: WhereBetween<TRecord, TResult>;
|
677 | andWhereNotBetween: WhereBetween<TRecord, TResult>;
|
678 |
|
679 | whereJsonObject: WhereJsonObject<TRecord, TResult>;
|
680 | orWhereJsonObject: WhereJsonObject<TRecord, TResult>;
|
681 | andWhereJsonObject: WhereJsonObject<TRecord, TResult>;
|
682 | whereNotJsonObject: WhereJsonObject<TRecord, TResult>;
|
683 | orWhereNotJsonObject: WhereJsonObject<TRecord, TResult>;
|
684 | andWhereNotJsonObject: WhereJsonObject<TRecord, TResult>;
|
685 |
|
686 | whereJsonPath: WhereJsonPath<TRecord, TResult>;
|
687 | orWhereJsonPath: WhereJsonPath<TRecord, TResult>;
|
688 | andWhereJsonPath: WhereJsonPath<TRecord, TResult>;
|
689 |
|
690 | whereJsonSupersetOf: WhereJsonObject<TRecord, TResult>;
|
691 | orWhereJsonSupersetOf: WhereJsonObject<TRecord, TResult>;
|
692 | andWhereJsonSupersetOf: WhereJsonObject<TRecord, TResult>;
|
693 | whereJsonNotSupersetOf: WhereJsonObject<TRecord, TResult>;
|
694 | orWhereJsonNotSupersetOf: WhereJsonObject<TRecord, TResult>;
|
695 | andWhereJsonNotSupersetOf: WhereJsonObject<TRecord, TResult>;
|
696 |
|
697 | whereJsonSubsetOf: WhereJsonObject<TRecord, TResult>;
|
698 | orWhereJsonSubsetOf: WhereJsonObject<TRecord, TResult>;
|
699 | andWhereJsonSubsetOf: WhereJsonObject<TRecord, TResult>;
|
700 | whereJsonNotSubsetOf: WhereJsonObject<TRecord, TResult>;
|
701 | orWhereJsonNotSubsetOf: WhereJsonObject<TRecord, TResult>;
|
702 | andWhereJsonNotSubsetOf: WhereJsonObject<TRecord, TResult>;
|
703 |
|
704 |
|
705 | groupBy: GroupBy<TRecord, TResult>;
|
706 | groupByRaw: RawQueryBuilder<TRecord, TResult>;
|
707 |
|
708 |
|
709 | orderBy: OrderBy<TRecord, TResult>;
|
710 | orderByRaw: RawQueryBuilder<TRecord, TResult>;
|
711 |
|
712 |
|
713 | partitionBy: PartitionBy<TRecord, TResult>;
|
714 |
|
715 |
|
716 | union: Union<TRecord, TResult>;
|
717 | unionAll: Union<TRecord, TResult>;
|
718 | intersect: Intersect<TRecord, TResult>;
|
719 | except: Except<TRecord, TResult>;
|
720 |
|
721 |
|
722 | having: Having<TRecord, TResult>;
|
723 | andHaving: Having<TRecord, TResult>;
|
724 | havingRaw: RawQueryBuilder<TRecord, TResult>;
|
725 | orHaving: Having<TRecord, TResult>;
|
726 | orHavingRaw: RawQueryBuilder<TRecord, TResult>;
|
727 | havingIn: HavingRange<TRecord, TResult>;
|
728 | orHavingNotBetween: HavingRange<TRecord, TResult>;
|
729 | havingNotBetween: HavingRange<TRecord, TResult>;
|
730 | orHavingBetween: HavingRange<TRecord, TResult>;
|
731 | havingBetween: HavingRange<TRecord, TResult>;
|
732 | havingNotIn: HavingRange<TRecord, TResult>;
|
733 | andHavingNotIn: HavingRange<TRecord, TResult>;
|
734 | orHavingNotIn: HavingRange<TRecord, TResult>;
|
735 | havingNull: HavingNull<TRecord, TResult>;
|
736 | havingNotNull: HavingNull<TRecord, TResult>;
|
737 | orHavingNull: HavingNull<TRecord, TResult>;
|
738 | orHavingNotNull: HavingNull<TRecord, TResult>;
|
739 |
|
740 |
|
741 | clearSelect(): QueryBuilder<
|
742 | TRecord,
|
743 | UnwrapArrayMember<TResult> extends DeferredKeySelection<
|
744 | infer TBase,
|
745 | infer TKeys,
|
746 | true,
|
747 | any,
|
748 | any,
|
749 | any,
|
750 | any
|
751 | >
|
752 | ? DeferredKeySelection<TBase, never>[]
|
753 | : TResult
|
754 | >;
|
755 | clearWhere(): QueryBuilder<TRecord, TResult>;
|
756 | clearGroup(): QueryBuilder<TRecord, TResult>;
|
757 | clearOrder(): QueryBuilder<TRecord, TResult>;
|
758 | clearHaving(): QueryBuilder<TRecord, TResult>;
|
759 | clearCounters(): QueryBuilder<TRecord, TResult>;
|
760 | clear(statement: ClearStatements): QueryBuilder<TRecord, TResult>;
|
761 |
|
762 |
|
763 | offset(
|
764 | offset: number,
|
765 | options?: boolean | Readonly<{ skipBinding?: boolean }>
|
766 | ): QueryBuilder<TRecord, TResult>;
|
767 | limit(
|
768 | limit: number,
|
769 | options?: string | Readonly<{ skipBinding?: boolean }>
|
770 | ): QueryBuilder<TRecord, TResult>;
|
771 |
|
772 |
|
773 | count: AsymmetricAggregation<
|
774 | TRecord,
|
775 | TResult,
|
776 | Lookup<ResultTypes.Registry, 'Count', number | string>
|
777 | >;
|
778 | countDistinct: AsymmetricAggregation<
|
779 | TRecord,
|
780 | TResult,
|
781 | Lookup<ResultTypes.Registry, 'Count', number | string>
|
782 | >;
|
783 | min: TypePreservingAggregation<TRecord, TResult>;
|
784 | max: TypePreservingAggregation<TRecord, TResult>;
|
785 | sum: TypePreservingAggregation<TRecord, TResult>;
|
786 | sumDistinct: TypePreservingAggregation<TRecord, TResult>;
|
787 | avg: TypePreservingAggregation<TRecord, TResult>;
|
788 | avgDistinct: TypePreservingAggregation<TRecord, TResult>;
|
789 |
|
790 | increment(
|
791 | columnName: keyof TRecord,
|
792 | amount?: number
|
793 | ): QueryBuilder<TRecord, number>;
|
794 | increment(
|
795 | columnName: string,
|
796 | amount?: number
|
797 | ): QueryBuilder<TRecord, number>;
|
798 | increment(columns: {
|
799 | [column in keyof TRecord]: number;
|
800 | }): QueryBuilder<TRecord, number>;
|
801 |
|
802 | decrement(
|
803 | columnName: keyof TRecord,
|
804 | amount?: number
|
805 | ): QueryBuilder<TRecord, number>;
|
806 | decrement(
|
807 | columnName: string,
|
808 | amount?: number
|
809 | ): QueryBuilder<TRecord, number>;
|
810 | decrement(columns: {
|
811 | [column in keyof TRecord]: number;
|
812 | }): QueryBuilder<TRecord, number>;
|
813 |
|
814 |
|
815 | rank: AnalyticFunction<TRecord, TResult>;
|
816 | denseRank: AnalyticFunction<TRecord, TResult>;
|
817 | rowNumber: AnalyticFunction<TRecord, TResult>;
|
818 |
|
819 |
|
820 | first: Select<
|
821 | TRecord,
|
822 | DeferredKeySelection.AddUnionMember<UnwrapArrayMember<TResult>, undefined>
|
823 | >;
|
824 |
|
825 | pluck<K extends keyof TRecord>(
|
826 | column: K
|
827 | ): QueryBuilder<TRecord, TRecord[K][]>;
|
828 | pluck<TResult2 extends {}>(column: string): QueryBuilder<TRecord, TResult2>;
|
829 |
|
830 | insert(
|
831 | data: TRecord extends CompositeTableType<unknown>
|
832 | ?
|
833 | | ResolveTableType<TRecord, 'insert'>
|
834 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
835 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
836 | returning: '*',
|
837 | options?: DMLOptions
|
838 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
839 | insert<
|
840 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
841 | TResult2 = DeferredKeySelection.Augment<
|
842 | UnwrapArrayMember<TResult>,
|
843 | ResolveTableType<TRecord>,
|
844 | TKey
|
845 | >[]
|
846 | >(
|
847 | data: TRecord extends CompositeTableType<unknown>
|
848 | ?
|
849 | | ResolveTableType<TRecord, 'insert'>
|
850 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
851 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
852 | returning: TKey,
|
853 | options?: DMLOptions
|
854 | ): QueryBuilder<TRecord, TResult2>;
|
855 | insert<
|
856 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
857 | TResult2 = DeferredKeySelection.Augment<
|
858 | UnwrapArrayMember<TResult>,
|
859 | ResolveTableType<TRecord>,
|
860 | TKey
|
861 | >[]
|
862 | >(
|
863 | data: TRecord extends CompositeTableType<unknown>
|
864 | ?
|
865 | | ResolveTableType<TRecord, 'insert'>
|
866 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
867 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
868 | returning: readonly TKey[],
|
869 | options?: DMLOptions
|
870 | ): QueryBuilder<TRecord, TResult2>;
|
871 | insert<
|
872 | TKey extends string,
|
873 | TResult2 = DeferredKeySelection.Augment<
|
874 | UnwrapArrayMember<TResult>,
|
875 | TRecord,
|
876 | TKey
|
877 | >[]
|
878 | >(
|
879 | data: TRecord extends CompositeTableType<unknown>
|
880 | ?
|
881 | | ResolveTableType<TRecord, 'insert'>
|
882 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
883 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
884 | returning: TKey,
|
885 | options?: DMLOptions
|
886 | ): QueryBuilder<TRecord, TResult2>;
|
887 | insert<
|
888 | TKey extends string,
|
889 | TResult2 = DeferredKeySelection.Augment<
|
890 | UnwrapArrayMember<TResult>,
|
891 | TRecord,
|
892 | TKey
|
893 | >[]
|
894 | >(
|
895 | data: TRecord extends CompositeTableType<unknown>
|
896 | ?
|
897 | | ResolveTableType<TRecord, 'insert'>
|
898 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
899 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
900 | returning: readonly TKey[],
|
901 | options?: DMLOptions
|
902 | ): QueryBuilder<TRecord, TResult2>;
|
903 | insert<TResult2 = number[]>(
|
904 | data: TRecord extends CompositeTableType<unknown>
|
905 | ?
|
906 | | ResolveTableType<TRecord, 'insert'>
|
907 | | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
908 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>
|
909 | ): QueryBuilder<TRecord, TResult2>;
|
910 |
|
911 | upsert(
|
912 | data: TRecord extends CompositeTableType<unknown>
|
913 | ?
|
914 | | ResolveTableType<TRecord, 'upsert'>
|
915 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
916 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
917 | returning: '*',
|
918 | options?: DMLOptions
|
919 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
920 | upsert<
|
921 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
922 | TResult2 = DeferredKeySelection.Augment<
|
923 | UnwrapArrayMember<TResult>,
|
924 | ResolveTableType<TRecord>,
|
925 | TKey
|
926 | >[]
|
927 | >(
|
928 | data: TRecord extends CompositeTableType<unknown>
|
929 | ?
|
930 | | ResolveTableType<TRecord, 'upsert'>
|
931 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
932 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
933 | returning: TKey,
|
934 | options?: DMLOptions
|
935 | ): QueryBuilder<TRecord, TResult2>;
|
936 | upsert<
|
937 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
938 | TResult2 = DeferredKeySelection.Augment<
|
939 | UnwrapArrayMember<TResult>,
|
940 | ResolveTableType<TRecord>,
|
941 | TKey
|
942 | >[]
|
943 | >(
|
944 | data: TRecord extends CompositeTableType<unknown>
|
945 | ?
|
946 | | ResolveTableType<TRecord, 'upsert'>
|
947 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
948 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
949 | returning: readonly TKey[],
|
950 | options?: DMLOptions
|
951 | ): QueryBuilder<TRecord, TResult2>;
|
952 | upsert<
|
953 | TKey extends string,
|
954 | TResult2 = DeferredKeySelection.Augment<
|
955 | UnwrapArrayMember<TResult>,
|
956 | TRecord,
|
957 | TKey
|
958 | >[]
|
959 | >(
|
960 | data: TRecord extends CompositeTableType<unknown>
|
961 | ?
|
962 | | ResolveTableType<TRecord, 'upsert'>
|
963 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
964 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
965 | returning: TKey,
|
966 | options?: DMLOptions
|
967 | ): QueryBuilder<TRecord, TResult2>;
|
968 | upsert<
|
969 | TKey extends string,
|
970 | TResult2 = DeferredKeySelection.Augment<
|
971 | UnwrapArrayMember<TResult>,
|
972 | TRecord,
|
973 | TKey
|
974 | >[]
|
975 | >(
|
976 | data: TRecord extends CompositeTableType<unknown>
|
977 | ?
|
978 | | ResolveTableType<TRecord, 'upsert'>
|
979 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
980 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
981 | returning: readonly TKey[],
|
982 | options?: DMLOptions
|
983 | ): QueryBuilder<TRecord, TResult2>;
|
984 | upsert<TResult2 = number[]>(
|
985 | data: TRecord extends CompositeTableType<unknown>
|
986 | ?
|
987 | | ResolveTableType<TRecord, 'upsert'>
|
988 | | ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
989 | : DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>
|
990 | ): QueryBuilder<TRecord, TResult2>;
|
991 |
|
992 | modify<TRecord2 extends {} = any, TResult2 extends {} = any>(
|
993 | callback: QueryCallbackWithArgs<TRecord, any>,
|
994 | ...args: any[]
|
995 | ): QueryBuilder<TRecord2, TResult2>;
|
996 | update<
|
997 | K1 extends StrKey<ResolveTableType<TRecord, 'update'>>,
|
998 | K2 extends StrKey<ResolveTableType<TRecord>>,
|
999 | TResult2 = DeferredKeySelection.Augment<
|
1000 | UnwrapArrayMember<TResult>,
|
1001 | ResolveTableType<TRecord>,
|
1002 | K2
|
1003 | >[]
|
1004 | >(
|
1005 | columnName: K1,
|
1006 | value: DbColumn<ResolveTableType<TRecord, 'update'>[K1]>,
|
1007 | returning: K2,
|
1008 | options?: DMLOptions
|
1009 | ): QueryBuilder<TRecord, TResult2>;
|
1010 | update<
|
1011 | K1 extends StrKey<ResolveTableType<TRecord, 'update'>>,
|
1012 | K2 extends StrKey<ResolveTableType<TRecord>>,
|
1013 | TResult2 = DeferredKeySelection.Augment<
|
1014 | UnwrapArrayMember<TResult>,
|
1015 | ResolveTableType<TRecord>,
|
1016 | K2
|
1017 | >[]
|
1018 | >(
|
1019 | columnName: K1,
|
1020 | value: DbColumn<ResolveTableType<TRecord, 'update'>[K1]>,
|
1021 | returning: readonly K2[],
|
1022 | options?: DMLOptions
|
1023 | ): QueryBuilder<TRecord, TResult2>;
|
1024 | update<K extends keyof TRecord>(
|
1025 | columnName: K,
|
1026 | value: DbColumn<TRecord[K]>
|
1027 | ): QueryBuilder<TRecord, number>;
|
1028 | update<TResult2 = SafePartial<TRecord>[]>(
|
1029 | columnName: string,
|
1030 | value: Value,
|
1031 | returning: string | readonly string[],
|
1032 | options?: DMLOptions
|
1033 | ): QueryBuilder<TRecord, TResult2>;
|
1034 | update(
|
1035 | data: DbRecordArr<TRecord>,
|
1036 | returning: '*',
|
1037 | options?: DMLOptions
|
1038 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
1039 | update<
|
1040 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
1041 | TResult2 = DeferredKeySelection.Augment<
|
1042 | UnwrapArrayMember<TResult>,
|
1043 | ResolveTableType<TRecord>,
|
1044 | TKey
|
1045 | >[]
|
1046 | >(
|
1047 | data: TRecord extends CompositeTableType<unknown>
|
1048 | ? ResolveTableType<TRecord, 'update'>
|
1049 | : DbRecordArr<TRecord>,
|
1050 | returning: TKey,
|
1051 | options?: DMLOptions
|
1052 | ): QueryBuilder<TRecord, TResult2>;
|
1053 | update<
|
1054 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
1055 | TResult2 = DeferredKeySelection.Augment<
|
1056 | UnwrapArrayMember<TResult>,
|
1057 | ResolveTableType<TRecord>,
|
1058 | TKey
|
1059 | >[]
|
1060 | >(
|
1061 | data: TRecord extends CompositeTableType<unknown>
|
1062 | ? ResolveTableType<TRecord, 'update'>
|
1063 | : DbRecordArr<TRecord>,
|
1064 | returning: readonly TKey[],
|
1065 | options?: DMLOptions
|
1066 | ): QueryBuilder<TRecord, TResult2>;
|
1067 | update<
|
1068 | TKey extends string = string,
|
1069 | TResult2 extends {}[] = DeferredKeySelection.Augment<
|
1070 | UnwrapArrayMember<TResult>,
|
1071 | TRecord,
|
1072 | TKey
|
1073 | >[]
|
1074 | >(
|
1075 | data: TRecord extends CompositeTableType<unknown>
|
1076 | ? ResolveTableType<TRecord, 'update'>
|
1077 | : DbRecordArr<TRecord>,
|
1078 | returning: TKey | readonly TKey[],
|
1079 | options?: DMLOptions
|
1080 | ): QueryBuilder<TRecord, TResult2>;
|
1081 | update<
|
1082 | TKey extends string,
|
1083 | TResult2 extends {}[] = DeferredKeySelection.Augment<
|
1084 | UnwrapArrayMember<TResult>,
|
1085 | TRecord,
|
1086 | TKey
|
1087 | >[]
|
1088 | >(
|
1089 | data: TRecord extends CompositeTableType<unknown>
|
1090 | ? ResolveTableType<TRecord, 'update'>
|
1091 | : DbRecordArr<TRecord>,
|
1092 | returning: readonly TKey[],
|
1093 | options?: DMLOptions
|
1094 | ): QueryBuilder<TRecord, TResult2>;
|
1095 | update<TResult2 = number>(
|
1096 | data: TRecord extends CompositeTableType<unknown>
|
1097 | ? ResolveTableType<TRecord, 'update'>
|
1098 | : DbRecordArr<TRecord>
|
1099 | ): QueryBuilder<TRecord, TResult2>;
|
1100 |
|
1101 | update<TResult2 = number>(
|
1102 | columnName: string,
|
1103 | value: Value
|
1104 | ): QueryBuilder<TRecord, TResult2>;
|
1105 |
|
1106 | returning(
|
1107 | column: '*',
|
1108 | options?: DMLOptions
|
1109 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
1110 | returning<
|
1111 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
1112 | TResult2 = DeferredKeySelection.Augment<
|
1113 | UnwrapArrayMember<TResult>,
|
1114 | ResolveTableType<TRecord>,
|
1115 | TKey
|
1116 | >[]
|
1117 | >(
|
1118 | column: TKey,
|
1119 | options?: DMLOptions
|
1120 | ): QueryBuilder<TRecord, TResult2>;
|
1121 | returning<
|
1122 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
1123 | TResult2 = DeferredKeySelection.SetSingle<
|
1124 | DeferredKeySelection.Augment<
|
1125 | UnwrapArrayMember<TResult>,
|
1126 | ResolveTableType<TRecord>,
|
1127 | TKey
|
1128 | >,
|
1129 | false
|
1130 | >[]
|
1131 | >(
|
1132 | columns: readonly TKey[],
|
1133 | options?: DMLOptions
|
1134 | ): QueryBuilder<TRecord, TResult2>;
|
1135 | returning<TResult2 = SafePartial<TRecord>[]>(
|
1136 | column: string | readonly (string | Raw)[] | Raw,
|
1137 | options?: DMLOptions
|
1138 | ): QueryBuilder<TRecord, TResult2>;
|
1139 |
|
1140 | onConflict<TKey extends StrKey<ResolveTableType<TRecord>>>(
|
1141 | column: TKey
|
1142 | ): OnConflictQueryBuilder<TRecord, TResult>;
|
1143 | onConflict<TKey extends StrKey<ResolveTableType<TRecord>>>(
|
1144 | columns: readonly TKey[]
|
1145 | ): OnConflictQueryBuilder<TRecord, TResult>;
|
1146 |
|
1147 | onConflict(columns: string): OnConflictQueryBuilder<TRecord, TResult>;
|
1148 |
|
1149 | onConflict(columns: string[]): OnConflictQueryBuilder<TRecord, TResult>;
|
1150 |
|
1151 | onConflict(raw: Raw): OnConflictQueryBuilder<TRecord, TResult>;
|
1152 |
|
1153 | onConflict(): OnConflictQueryBuilder<TRecord, TResult>;
|
1154 |
|
1155 | updateFrom: Table<TRecord, TResult>;
|
1156 |
|
1157 | del(
|
1158 | returning: '*',
|
1159 | options?: DMLOptions
|
1160 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
1161 | del<
|
1162 | TKey extends StrKey<TRecord>,
|
1163 | TResult2 = DeferredKeySelection.Augment<
|
1164 | UnwrapArrayMember<TResult>,
|
1165 | TRecord,
|
1166 | TKey
|
1167 | >[]
|
1168 | >(
|
1169 | returning: TKey,
|
1170 | options?: DMLOptions
|
1171 | ): QueryBuilder<TRecord, TResult2>;
|
1172 | del<
|
1173 | TKey extends StrKey<TRecord>,
|
1174 | TResult2 = DeferredKeySelection.Augment<
|
1175 | UnwrapArrayMember<TResult>,
|
1176 | TRecord,
|
1177 | TKey
|
1178 | >[]
|
1179 | >(
|
1180 | returning: readonly TKey[],
|
1181 | options?: DMLOptions
|
1182 | ): QueryBuilder<TRecord, TResult2[]>;
|
1183 | del<TResult2 = SafePartial<TRecord>[]>(
|
1184 | returning: string | readonly string[],
|
1185 | options?: DMLOptions
|
1186 | ): QueryBuilder<TRecord, TResult2>;
|
1187 | del<TResult2 = number>(): QueryBuilder<TRecord, TResult2>;
|
1188 |
|
1189 | delete(
|
1190 | returning: '*',
|
1191 | options?: DMLOptions
|
1192 | ): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
1193 | delete<
|
1194 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
1195 | TResult2 = DeferredKeySelection.Augment<
|
1196 | UnwrapArrayMember<TResult>,
|
1197 | ResolveTableType<TRecord>,
|
1198 | TKey
|
1199 | >[]
|
1200 | >(
|
1201 | returning: TKey,
|
1202 | options?: DMLOptions
|
1203 | ): QueryBuilder<TRecord, TResult2>;
|
1204 | delete<
|
1205 | TKey extends StrKey<TRecord>,
|
1206 | TResult2 = DeferredKeySelection.Augment<
|
1207 | UnwrapArrayMember<TResult>,
|
1208 | TRecord,
|
1209 | TKey
|
1210 | >[]
|
1211 | >(
|
1212 | returning: readonly TKey[],
|
1213 | options?: DMLOptions
|
1214 | ): QueryBuilder<TRecord, TResult2>;
|
1215 | delete<TResult2 = any>(
|
1216 | returning: string | readonly (string | Raw)[] | Raw,
|
1217 | options?: DMLOptions
|
1218 | ): QueryBuilder<TRecord, TResult2>;
|
1219 | delete<TResult2 = number>(): QueryBuilder<TRecord, TResult2>;
|
1220 |
|
1221 | truncate(): QueryBuilder<TRecord, void>;
|
1222 | }
|
1223 |
|
1224 | interface As<TRecord extends {}, TResult> {
|
1225 | (columnName: keyof TRecord): QueryBuilder<TRecord, TResult>;
|
1226 | (columnName: string): QueryBuilder<TRecord, TResult>;
|
1227 | }
|
1228 |
|
1229 | type IntersectAliases<AliasUT> = UnionToIntersection<
|
1230 | IncompatibleToAlt<
|
1231 | AliasUT extends (infer I)[]
|
1232 | ? I extends Ref<any, infer TMapping>
|
1233 | ? TMapping
|
1234 | : I
|
1235 | : never,
|
1236 | Dict,
|
1237 | {}
|
1238 | >
|
1239 | > & {};
|
1240 |
|
1241 | interface AliasQueryBuilder<TRecord extends {} = any, TResult = unknown[]> {
|
1242 | <
|
1243 | AliasUT extends InferrableColumnDescriptor<ResolveTableType<TRecord>>[],
|
1244 | TResult2 = ArrayIfAlready<
|
1245 | TResult,
|
1246 | DeferredKeySelection.Augment<
|
1247 | UnwrapArrayMember<TResult>,
|
1248 | ResolveTableType<TRecord>,
|
1249 | IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
1250 | IntersectAliases<AliasUT>
|
1251 | >
|
1252 | >
|
1253 | >(
|
1254 | ...aliases: AliasUT
|
1255 | ): QueryBuilder<TRecord, TResult2>;
|
1256 |
|
1257 | <
|
1258 | AliasUT extends InferrableColumnDescriptor<ResolveTableType<TRecord>>[],
|
1259 | TResult2 = ArrayIfAlready<
|
1260 | TResult,
|
1261 | DeferredKeySelection.Augment<
|
1262 | UnwrapArrayMember<TResult>,
|
1263 | ResolveTableType<TRecord>,
|
1264 | IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
1265 | IntersectAliases<AliasUT>
|
1266 | >
|
1267 | >
|
1268 | >(
|
1269 | aliases: AliasUT
|
1270 | ): QueryBuilder<TRecord, TResult2>;
|
1271 |
|
1272 | <
|
1273 | AliasUT extends (Dict | string)[],
|
1274 | TResult2 = ArrayIfAlready<
|
1275 | TResult,
|
1276 | DeferredKeySelection.Augment<
|
1277 | UnwrapArrayMember<TResult>,
|
1278 | ResolveTableType<TRecord>,
|
1279 | IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
1280 | IntersectAliases<AliasUT>
|
1281 | >
|
1282 | >
|
1283 | >(
|
1284 | ...aliases: AliasUT
|
1285 | ): QueryBuilder<TRecord, TResult2>;
|
1286 |
|
1287 | <
|
1288 | AliasUT extends (Dict | string)[],
|
1289 | TResult2 = ArrayIfAlready<
|
1290 | TResult,
|
1291 | DeferredKeySelection.Augment<
|
1292 | UnwrapArrayMember<TResult>,
|
1293 | TRecord,
|
1294 | IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
1295 | IntersectAliases<AliasUT>
|
1296 | >
|
1297 | >
|
1298 | >(
|
1299 | aliases: AliasUT
|
1300 | ): QueryBuilder<TRecord, TResult2>;
|
1301 | }
|
1302 |
|
1303 | interface Select<TRecord extends {} = any, TResult = unknown[]>
|
1304 | extends AliasQueryBuilder<TRecord, TResult>,
|
1305 | ColumnNameQueryBuilder<TRecord, TResult> {
|
1306 | (): QueryBuilder<TRecord, TResult>;
|
1307 |
|
1308 | <
|
1309 | TResult2 = ArrayIfAlready<TResult, any>,
|
1310 | TInnerRecord extends {} = any,
|
1311 | TInnerResult = any
|
1312 | >(
|
1313 | ...subQueryBuilders: readonly QueryBuilder<TInnerRecord, TInnerResult>[]
|
1314 | ): QueryBuilder<TRecord, TResult2>;
|
1315 |
|
1316 | <
|
1317 | TResult2 = ArrayIfAlready<TResult, any>,
|
1318 | TInnerRecord extends {} = any,
|
1319 | TInnerResult = any
|
1320 | >(
|
1321 | subQueryBuilders: readonly QueryBuilder<TInnerRecord, TInnerResult>[]
|
1322 | ): QueryBuilder<TRecord, TResult2>;
|
1323 | }
|
1324 |
|
1325 | interface JsonExtraction {
|
1326 | column: string | Raw | QueryBuilder;
|
1327 | path: string;
|
1328 | alias?: string;
|
1329 | singleValue?: boolean;
|
1330 | }
|
1331 |
|
1332 | interface JsonExtract<TRecord extends {} = any, TResult = any> {
|
1333 | (
|
1334 | column: string | Raw | QueryBuilder,
|
1335 | path: string,
|
1336 | alias?: string,
|
1337 | singleValue?: boolean
|
1338 | ): QueryBuilder<TRecord, TResult>;
|
1339 | (column: JsonExtraction[] | any[][], singleValue?: boolean): QueryBuilder<
|
1340 | TRecord,
|
1341 | TResult
|
1342 | >;
|
1343 | }
|
1344 |
|
1345 | interface JsonSet<TRecord extends {} = any, TResult = any> {
|
1346 | (
|
1347 | column: string | Raw | QueryBuilder,
|
1348 | path: string,
|
1349 | value: any,
|
1350 | alias?: string
|
1351 | ): QueryBuilder<TRecord, TResult>;
|
1352 | }
|
1353 |
|
1354 | interface JsonInsert<TRecord extends {} = any, TResult = any> {
|
1355 | (
|
1356 | column: string | Raw | QueryBuilder,
|
1357 | path: string,
|
1358 | value: any,
|
1359 | alias?: string
|
1360 | ): QueryBuilder<TRecord, TResult>;
|
1361 | }
|
1362 |
|
1363 | interface JsonRemove<TRecord extends {} = any, TResult = any> {
|
1364 | (
|
1365 | column: string | Raw | QueryBuilder,
|
1366 | path: string,
|
1367 | alias?: string
|
1368 | ): QueryBuilder<TRecord, TResult>;
|
1369 | }
|
1370 |
|
1371 | interface Comment<TRecord extends {} = any, TResult = any> {
|
1372 | (comment: string): QueryBuilder<TRecord, TResult>;
|
1373 | }
|
1374 |
|
1375 | interface HintComment<TRecord extends {} = any, TResult = any> {
|
1376 | (hint: string): QueryBuilder<TRecord, TResult>;
|
1377 | (hints: readonly string[]): QueryBuilder<TRecord, TResult>;
|
1378 | }
|
1379 |
|
1380 | interface Table<TRecord extends {} = any, TResult = any> {
|
1381 | <
|
1382 | TTable extends TableNames,
|
1383 | TRecord2 extends {} = TableType<TTable>,
|
1384 | TResult2 = DeferredKeySelection.ReplaceBase<
|
1385 | TResult,
|
1386 | ResolveTableType<TRecord2>
|
1387 | >
|
1388 | >(
|
1389 | tableName: TTable,
|
1390 | options?: TableOptions
|
1391 | ): QueryBuilder<TRecord2, TResult2>;
|
1392 | <
|
1393 | TRecord2 extends {} = {},
|
1394 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1395 | >(
|
1396 | tableName: TableDescriptor | AliasDict,
|
1397 | options?: TableOptions
|
1398 | ): QueryBuilder<TRecord2, TResult2>;
|
1399 | <
|
1400 | TRecord2 extends {} = {},
|
1401 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1402 | >(
|
1403 | callback: Function,
|
1404 | options?: TableOptions
|
1405 | ): QueryBuilder<TRecord2, TResult2>;
|
1406 | <
|
1407 | TRecord2 extends {} = {},
|
1408 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1409 | >(
|
1410 | raw: Raw,
|
1411 | options?: TableOptions
|
1412 | ): QueryBuilder<TRecord2, TResult2>;
|
1413 | }
|
1414 |
|
1415 | interface Distinct<TRecord extends {}, TResult = {}[]>
|
1416 | extends ColumnNameQueryBuilder<TRecord, TResult> {}
|
1417 |
|
1418 | interface DistinctOn<TRecord extends {}, TResult = {}[]> {
|
1419 | <ColNameUT extends keyof TRecord>(
|
1420 | ...columnNames: readonly ColNameUT[]
|
1421 | ): QueryBuilder<TRecord, TResult>;
|
1422 |
|
1423 | <ColNameUT extends keyof TRecord>(
|
1424 | columnNames: readonly ColNameUT[]
|
1425 | ): QueryBuilder<TRecord, TResult>;
|
1426 |
|
1427 | (...columnNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
1428 | (columnNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
1429 | }
|
1430 |
|
1431 | interface JoinCallback {
|
1432 | (this: JoinClause, join: JoinClause): void;
|
1433 | }
|
1434 |
|
1435 | interface Join<TRecord extends {} = any, TResult = unknown[]> {
|
1436 | <
|
1437 | TJoinTargetRecord extends {} = any,
|
1438 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1439 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1440 | >(
|
1441 | raw: Raw
|
1442 | ): QueryBuilder<TRecord2, TResult2>;
|
1443 | <
|
1444 | TTable extends TableNames,
|
1445 | TRecord2 extends {} = ResolveTableType<TRecord> &
|
1446 | ResolveTableType<TableType<TTable>>,
|
1447 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1448 | >(
|
1449 | tableName: TTable,
|
1450 | clause: JoinCallback
|
1451 | ): QueryBuilder<TRecord2, TResult2>;
|
1452 | <
|
1453 | TJoinTargetRecord extends {} = any,
|
1454 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1455 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1456 | >(
|
1457 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1458 | clause: JoinCallback
|
1459 | ): QueryBuilder<TRecord2, TResult2>;
|
1460 | <
|
1461 | TJoinTargetRecord extends {} = any,
|
1462 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1463 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1464 | >(
|
1465 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1466 | columns: { [key: string]: string | number | boolean | Raw }
|
1467 | ): QueryBuilder<TRecord2, TResult2>;
|
1468 | <
|
1469 | TJoinTargetRecord extends {} = any,
|
1470 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1471 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1472 | >(
|
1473 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1474 | raw: Raw
|
1475 | ): QueryBuilder<TRecord2, TResult2>;
|
1476 | <
|
1477 | TTable1 extends TableNames,
|
1478 | TTable2 extends TableNames,
|
1479 | TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
1480 | StrKey<TRecord1>,
|
1481 | TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
1482 | TRecord1 = ResolveTableType<TRecord>,
|
1483 | TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
1484 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1485 | >(
|
1486 | tableName: TTable2,
|
1487 | column1: `${TTable1}.${TKey1}`,
|
1488 | column2: `${TTable2}.${TKey2}`
|
1489 | ): QueryBuilder<TRecord2, TResult2>;
|
1490 | <
|
1491 | TTable1 extends TableNames,
|
1492 | TTable2 extends TableNames,
|
1493 | TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
1494 | StrKey<TRecord1>,
|
1495 | TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
1496 | TRecord1 = ResolveTableType<TRecord>,
|
1497 | TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
1498 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1499 | >(
|
1500 | tableName: TTable2,
|
1501 | column1: `${TTable2}.${TKey2}`,
|
1502 | column2: `${TTable1}.${TKey1}`
|
1503 | ): QueryBuilder<TRecord2, TResult2>;
|
1504 | <
|
1505 | TJoinTargetRecord extends {} = any,
|
1506 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1507 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1508 | >(
|
1509 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1510 | column1: string,
|
1511 | column2: string
|
1512 | ): QueryBuilder<TRecord2, TResult2>;
|
1513 | <
|
1514 | TJoinTargetRecord extends {} = any,
|
1515 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1516 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1517 | >(
|
1518 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1519 | column1: string,
|
1520 | raw: Raw
|
1521 | ): QueryBuilder<TRecord2, TResult2>;
|
1522 | <
|
1523 | TTable1 extends TableNames,
|
1524 | TTable2 extends TableNames,
|
1525 | TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
1526 | StrKey<TRecord1>,
|
1527 | TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
1528 | TRecord1 = ResolveTableType<TRecord>,
|
1529 | TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
1530 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1531 | >(
|
1532 | tableName: TTable2,
|
1533 | column1: `${TTable1}.${TKey1}`,
|
1534 | operator: string,
|
1535 | column2: `${TTable2}.${TKey2}`
|
1536 | ): QueryBuilder<TRecord2, TResult2>;
|
1537 | <
|
1538 | TTable1 extends TableNames,
|
1539 | TTable2 extends TableNames,
|
1540 | TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
1541 | StrKey<TRecord1>,
|
1542 | TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
1543 | TRecord1 = ResolveTableType<TRecord>,
|
1544 | TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
1545 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1546 | >(
|
1547 | tableName: TTable2,
|
1548 | column1: `${TTable2}.${TKey2}`,
|
1549 | operator: string,
|
1550 | column2: `${TTable1}.${TKey1}`
|
1551 | ): QueryBuilder<TRecord2, TResult2>;
|
1552 | <
|
1553 | TJoinTargetRecord extends {} = any,
|
1554 | TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
1555 | TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
1556 | >(
|
1557 | tableName: TableDescriptor | AliasDict | QueryCallback,
|
1558 | column1: string,
|
1559 | operator: string,
|
1560 | column2: string
|
1561 | ): QueryBuilder<TRecord2, TResult2>;
|
1562 | }
|
1563 |
|
1564 | interface JoinClause {
|
1565 | on(raw: Raw): JoinClause;
|
1566 | on(callback: JoinCallback): JoinClause;
|
1567 | on(columns: { [key: string]: string | Raw }): JoinClause;
|
1568 | on(column1: string, column2: string): JoinClause;
|
1569 | on(column1: string, raw: Raw): JoinClause;
|
1570 | on(column1: string, operator: string, column2: string | Raw): JoinClause;
|
1571 | andOn(raw: Raw): JoinClause;
|
1572 | andOn(callback: JoinCallback): JoinClause;
|
1573 | andOn(columns: { [key: string]: string | Raw }): JoinClause;
|
1574 | andOn(column1: string, column2: string): JoinClause;
|
1575 | andOn(column1: string, raw: Raw): JoinClause;
|
1576 | andOn(column1: string, operator: string, column2: string | Raw): JoinClause;
|
1577 | orOn(raw: Raw): JoinClause;
|
1578 | orOn(callback: JoinCallback): JoinClause;
|
1579 | orOn(columns: { [key: string]: string | Raw }): JoinClause;
|
1580 | orOn(column1: string, column2: string): JoinClause;
|
1581 | orOn(column1: string, raw: Raw): JoinClause;
|
1582 | orOn(column1: string, operator: string, column2: string | Raw): JoinClause;
|
1583 | onVal(column1: string, value: Value): JoinClause;
|
1584 | onVal(column1: string, operator: string, value: Value): JoinClause;
|
1585 | andOnVal(column1: string, value: Value): JoinClause;
|
1586 | andOnVal(column1: string, operator: string, value: Value): JoinClause;
|
1587 | orOnVal(column1: string, value: Value): JoinClause;
|
1588 | orOnVal(column1: string, operator: string, value: Value): JoinClause;
|
1589 | onIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1590 | andOnIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1591 | orOnIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1592 | onNotIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1593 | andOnNotIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1594 | orOnNotIn(column1: string, values: readonly any[] | Raw): JoinClause;
|
1595 | onNull(column1: string): JoinClause;
|
1596 | andOnNull(column1: string): JoinClause;
|
1597 | orOnNull(column1: string): JoinClause;
|
1598 | onNotNull(column1: string): JoinClause;
|
1599 | andOnNotNull(column1: string): JoinClause;
|
1600 | orOnNotNull(column1: string): JoinClause;
|
1601 | onExists(callback: QueryCallback): JoinClause;
|
1602 | andOnExists(callback: QueryCallback): JoinClause;
|
1603 | orOnExists(callback: QueryCallback): JoinClause;
|
1604 | onNotExists(callback: QueryCallback): JoinClause;
|
1605 | andOnNotExists(callback: QueryCallback): JoinClause;
|
1606 | orOnNotExists(callback: QueryCallback): JoinClause;
|
1607 | onBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1608 | andOnBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1609 | orOnBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1610 | onNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1611 | andOnNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1612 | orOnNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
1613 | onJsonPathEquals(
|
1614 | columnFirst: string,
|
1615 | jsonPathFirst: string,
|
1616 | columnSecond: string,
|
1617 | jsonPathSecond: string
|
1618 | ): JoinClause;
|
1619 | orOnJsonPathEquals(
|
1620 | columnFirst: string,
|
1621 | jsonPathFirst: string,
|
1622 | columnSecond: string,
|
1623 | jsonPathSecond: string
|
1624 | ): JoinClause;
|
1625 | using(
|
1626 | column: string | readonly string[] | Raw | { [key: string]: string | Raw }
|
1627 | ): JoinClause;
|
1628 | type(type: string): JoinClause;
|
1629 | }
|
1630 |
|
1631 | interface JoinRaw<TRecord extends {} = any, TResult = unknown[]> {
|
1632 | (tableName: string, binding?: Value | Value[] | ValueDict): QueryBuilder<
|
1633 | TRecord,
|
1634 | TResult
|
1635 | >;
|
1636 | }
|
1637 |
|
1638 | interface Using<TRecord extends {} = any, TResult = unknown[]> {
|
1639 | (tables: string[]): QueryBuilder<TRecord, TResult>;
|
1640 | }
|
1641 |
|
1642 | interface With<TRecord extends {} = any, TResult = unknown[]>
|
1643 | extends WithRaw<TRecord, TResult>,
|
1644 | WithWrapped<TRecord, TResult> {}
|
1645 |
|
1646 | interface WithRaw<TRecord extends {} = any, TResult = unknown[]> {
|
1647 | (alias: string, raw: Raw | QueryBuilder): QueryBuilder<TRecord, TResult>;
|
1648 | (
|
1649 | alias: string,
|
1650 | sql: string,
|
1651 | bindings?: readonly Value[] | Object
|
1652 | ): QueryBuilder<TRecord, TResult>;
|
1653 | (
|
1654 | alias: string,
|
1655 | columnList: string[],
|
1656 | raw: Raw | QueryBuilder
|
1657 | ): QueryBuilder<TRecord, TResult>;
|
1658 | (
|
1659 | alias: string,
|
1660 | columnList: string[],
|
1661 | sql: string,
|
1662 | bindings?: readonly Value[] | Object
|
1663 | ): QueryBuilder<TRecord, TResult>;
|
1664 | }
|
1665 |
|
1666 | interface WithSchema<TRecord extends {} = any, TResult = unknown[]> {
|
1667 | (schema: string): QueryBuilder<TRecord, TResult>;
|
1668 | }
|
1669 |
|
1670 | interface WithWrapped<TRecord extends {} = any, TResult = unknown[]> {
|
1671 | (alias: string, queryBuilder: QueryBuilder): QueryBuilder<TRecord, TResult>;
|
1672 | (
|
1673 | alias: string,
|
1674 | callback: (queryBuilder: QueryBuilder) => any
|
1675 | ): QueryBuilder<TRecord, TResult>;
|
1676 | (
|
1677 | alias: string,
|
1678 | columnList: string[],
|
1679 | queryBuilder: QueryBuilder
|
1680 | ): QueryBuilder<TRecord, TResult>;
|
1681 | (
|
1682 | alias: string,
|
1683 | columnList: string[],
|
1684 | callback: (queryBuilder: QueryBuilder) => any
|
1685 | ): QueryBuilder<TRecord, TResult>;
|
1686 | }
|
1687 |
|
1688 | interface Where<TRecord extends {} = any, TResult = unknown>
|
1689 | extends WhereRaw<TRecord, TResult>,
|
1690 | WhereWrapped<TRecord, TResult>,
|
1691 | WhereNull<TRecord, TResult> {
|
1692 | (raw: Raw): QueryBuilder<TRecord, TResult>;
|
1693 |
|
1694 | (callback: QueryCallback<TRecord, TResult>): QueryBuilder<TRecord, TResult>;
|
1695 |
|
1696 | (object: DbRecord<ResolveTableType<TRecord>>): QueryBuilder<
|
1697 | TRecord,
|
1698 | TResult
|
1699 | >;
|
1700 |
|
1701 | (object: Readonly<Object>): QueryBuilder<TRecord, TResult>;
|
1702 |
|
1703 | <T extends keyof ResolveTableType<TRecord>>(
|
1704 | columnName: T,
|
1705 | value: DbColumn<ResolveTableType<TRecord>[T]> | null
|
1706 | ): QueryBuilder<TRecord, TResult>;
|
1707 |
|
1708 | (columnName: string, value: Value | null): QueryBuilder<TRecord, TResult>;
|
1709 |
|
1710 | <T extends keyof ResolveTableType<TRecord>>(
|
1711 | columnName: T,
|
1712 | operator: ComparisonOperator,
|
1713 | value: DbColumn<ResolveTableType<TRecord>[T]> | null
|
1714 | ): QueryBuilder<TRecord, TResult>;
|
1715 |
|
1716 | (columnName: string, operator: string, value: Value | null): QueryBuilder<
|
1717 | TRecord,
|
1718 | TResult
|
1719 | >;
|
1720 |
|
1721 | <
|
1722 | T extends keyof ResolveTableType<TRecord>,
|
1723 | TRecordInner extends {},
|
1724 | TResultInner
|
1725 | >(
|
1726 | columnName: T,
|
1727 | operator: ComparisonOperator,
|
1728 | value: QueryBuilder<TRecordInner, TResultInner>
|
1729 | ): QueryBuilder<TRecord, TResult>;
|
1730 |
|
1731 | <TRecordInner extends {}, TResultInner>(
|
1732 | columnName: string,
|
1733 | operator: string,
|
1734 | value: QueryBuilder<TRecordInner, TResultInner>
|
1735 | ): QueryBuilder<TRecord, TResult>;
|
1736 |
|
1737 | (left: Raw, operator: string, right: Value | null): QueryBuilder<
|
1738 | TRecord,
|
1739 | TResult
|
1740 | >;
|
1741 |
|
1742 | <TRecordInner extends {}, TResultInner>(
|
1743 | left: Raw,
|
1744 | operator: string,
|
1745 | right: QueryBuilder<TRecordInner, TResultInner>
|
1746 | ): QueryBuilder<TRecord, TResult>;
|
1747 | }
|
1748 |
|
1749 | interface WhereRaw<TRecord extends {} = any, TResult = unknown[]>
|
1750 | extends RawQueryBuilder<TRecord, TResult> {
|
1751 | (condition: boolean): QueryBuilder<TRecord, TResult>;
|
1752 | }
|
1753 |
|
1754 | interface WhereWrapped<TRecord extends {} = any, TResult = unknown[]> {
|
1755 | (callback: QueryCallback<TRecord, TResult>): QueryBuilder<TRecord, TResult>;
|
1756 | }
|
1757 |
|
1758 | interface WhereNull<TRecord extends {} = any, TResult = unknown[]> {
|
1759 | (columnName: keyof TRecord): QueryBuilder<TRecord, TResult>;
|
1760 | (columnName: string): QueryBuilder<TRecord, TResult>;
|
1761 | }
|
1762 |
|
1763 | interface WhereBetween<TRecord extends {} = any, TResult = unknown[]> {
|
1764 | <K extends keyof TRecord>(
|
1765 | columnName: K,
|
1766 | range: readonly [DbColumn<TRecord[K]>, DbColumn<TRecord[K]>]
|
1767 | ): QueryBuilder<TRecord, TResult>;
|
1768 | (columnName: string, range: readonly [Value, Value]): QueryBuilder<
|
1769 | TRecord,
|
1770 | TResult
|
1771 | >;
|
1772 | }
|
1773 |
|
1774 | interface WhereExists<TRecord extends {} = any, TResult = unknown[]> {
|
1775 | (callback: QueryCallback<TRecord, TResult>): QueryBuilder<TRecord, TResult>;
|
1776 | <TRecordInner extends {}, TResultInner>(
|
1777 | query: QueryBuilder<TRecordInner, TResultInner>
|
1778 | ): QueryBuilder<TRecord, TResult>;
|
1779 | }
|
1780 |
|
1781 | interface WhereJsonObject<TRecord extends {} = any, TResult = unknown[]> {
|
1782 | (columnName: keyof ResolveTableType<TRecord>, value: any): QueryBuilder<
|
1783 | TRecord,
|
1784 | TResult
|
1785 | >;
|
1786 | }
|
1787 |
|
1788 | interface WhereJsonPath<TRecord extends {} = any, TResult = unknown[]> {
|
1789 | (
|
1790 | columnName: keyof ResolveTableType<TRecord>,
|
1791 | jsonPath: string,
|
1792 | operator: string,
|
1793 | value: any
|
1794 | ): QueryBuilder<TRecord, TResult>;
|
1795 | }
|
1796 |
|
1797 | interface WhereIn<TRecord extends {} = any, TResult = unknown[]> {
|
1798 | <K extends keyof ResolveTableType<TRecord>>(
|
1799 | columnName: K,
|
1800 | values: readonly DbColumn<ResolveTableType<TRecord>[K]>[] | QueryCallback
|
1801 | ): QueryBuilder<TRecord, TResult>;
|
1802 | (
|
1803 | columnName: string,
|
1804 | values: readonly Value[] | QueryCallback
|
1805 | ): QueryBuilder<TRecord, TResult>;
|
1806 | <K extends keyof ResolveTableType<TRecord>>(
|
1807 | columnNames: readonly K[],
|
1808 | values:
|
1809 | | readonly (readonly DbColumn<ResolveTableType<TRecord>[K]>[])[]
|
1810 | | QueryCallback
|
1811 | ): QueryBuilder<TRecord, TResult>;
|
1812 | (
|
1813 | columnNames: readonly string[],
|
1814 | values: readonly Value[][] | QueryCallback
|
1815 | ): QueryBuilder<TRecord, TResult>;
|
1816 | <K extends keyof TRecord, TRecordInner extends {}, TResultInner>(
|
1817 | columnName: K,
|
1818 | values: QueryBuilder<TRecordInner, TRecord[K]>
|
1819 | ): QueryBuilder<TRecord, TResult>;
|
1820 | <TRecordInner extends {}, TResultInner>(
|
1821 | columnName: string,
|
1822 | values: Value[] | QueryBuilder<TRecordInner, TResultInner>
|
1823 | ): QueryBuilder<TRecord, TResult>;
|
1824 | <K extends keyof TRecord, TRecordInner extends {}, TResultInner>(
|
1825 | columnNames: readonly K[],
|
1826 | values: QueryBuilder<TRecordInner, TRecord[K]>
|
1827 | ): QueryBuilder<TRecord, TResult>;
|
1828 | <TRecordInner extends {}, TResultInner>(
|
1829 | columnNames: readonly string[],
|
1830 | values: QueryBuilder<TRecordInner, TResultInner>
|
1831 | ): QueryBuilder<TRecord, TResult>;
|
1832 | }
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 | interface AsymmetricAggregation<
|
1839 | TRecord extends {} = any,
|
1840 | TResult = unknown[],
|
1841 | TValue = any
|
1842 | > {
|
1843 | <
|
1844 | TOptions extends { as: string },
|
1845 | TResult2 = AggregationQueryResult<
|
1846 | TResult,
|
1847 | { [k in TOptions['as']]: TValue }
|
1848 | >
|
1849 | >(
|
1850 | columnName: Readonly<keyof ResolveTableType<TRecord>>,
|
1851 | options: Readonly<TOptions>
|
1852 | ): QueryBuilder<TRecord, TResult2>;
|
1853 | <TResult2 = AggregationQueryResult<TResult, Dict<TValue>>>(
|
1854 | ...columnNames: readonly (keyof ResolveTableType<TRecord>)[]
|
1855 | ): QueryBuilder<TRecord, TResult2>;
|
1856 | <
|
1857 | TAliases extends {} = Record<string, string | string[] | Knex.Raw>,
|
1858 | TResult2 = AggregationQueryResult<
|
1859 | TResult,
|
1860 | { [k in keyof TAliases]?: TValue }
|
1861 | >
|
1862 | >(
|
1863 | aliases: TAliases
|
1864 | ): QueryBuilder<TRecord, TResult2>;
|
1865 | <TResult2 = AggregationQueryResult<TResult, Dict<TValue>>>(
|
1866 | ...columnNames: ReadonlyArray<
|
1867 | | Readonly<Record<string, string | string[] | Knex.Raw>>
|
1868 | | Knex.Raw
|
1869 | | string
|
1870 | >
|
1871 | ): QueryBuilder<TRecord, TResult2>;
|
1872 | }
|
1873 |
|
1874 | interface TypePreservingAggregation<
|
1875 | TRecord extends {} = any,
|
1876 | TResult = unknown[],
|
1877 | TValue = any
|
1878 | > {
|
1879 | <
|
1880 | TKey extends keyof ResolveTableType<TRecord>,
|
1881 | TOptions extends { as: string },
|
1882 | TResult2 = AggregationQueryResult<
|
1883 | TResult,
|
1884 | {
|
1885 | [k in TOptions['as']]: ResolveTableType<TRecord>[TKey];
|
1886 | }
|
1887 | >
|
1888 | >(
|
1889 | columnName: TKey,
|
1890 | options: Readonly<TOptions>
|
1891 | ): QueryBuilder<TRecord, TResult2>;
|
1892 | <
|
1893 | TKey extends keyof ResolveTableType<TRecord>,
|
1894 | TResult2 = AggregationQueryResult<
|
1895 | TResult,
|
1896 | Dict<ResolveTableType<TRecord>[TKey]>
|
1897 | >
|
1898 | >(
|
1899 | ...columnNames: readonly TKey[]
|
1900 | ): QueryBuilder<TRecord, TResult2>;
|
1901 | <
|
1902 | TAliases extends {} = Readonly<
|
1903 | Record<string, string | string[] | Knex.Raw>
|
1904 | >,
|
1905 | TResult2 = AggregationQueryResult<
|
1906 | TResult,
|
1907 | {
|
1908 |
|
1909 |
|
1910 | [K in keyof TAliases]?: K extends keyof TRecord ? TRecord[K] : TValue;
|
1911 | }
|
1912 | >
|
1913 | >(
|
1914 | aliases: TAliases
|
1915 | ): QueryBuilder<TRecord, TResult2>;
|
1916 | <TResult2 = AggregationQueryResult<TResult, Dict<TValue>>>(
|
1917 | ...columnNames: ReadonlyArray<
|
1918 | | Readonly<Record<string, string | readonly string[] | Knex.Raw>>
|
1919 | | Knex.Raw
|
1920 | | string
|
1921 | >
|
1922 | ): QueryBuilder<TRecord, TResult2>;
|
1923 | }
|
1924 |
|
1925 | interface AnalyticFunction<TRecord extends {} = any, TResult = unknown[]> {
|
1926 | <
|
1927 | TAlias extends string,
|
1928 | TResult2 = AggregationQueryResult<TResult, { [x in TAlias]: number }>
|
1929 | >(
|
1930 | alias: TAlias,
|
1931 | raw: Raw | QueryCallback<TRecord, TResult>
|
1932 | ): QueryBuilder<TRecord, TResult2>;
|
1933 | <
|
1934 | TAlias extends string,
|
1935 | TKey extends keyof ResolveTableType<TRecord>,
|
1936 | TResult2 = AggregationQueryResult<TResult, { [x in TAlias]: number }>
|
1937 | >(
|
1938 | alias: TAlias,
|
1939 | orderBy:
|
1940 | | TKey
|
1941 | | TKey[]
|
1942 | | {
|
1943 | column: TKey;
|
1944 | order?: 'asc' | 'desc';
|
1945 | nulls?: 'first' | 'last';
|
1946 | },
|
1947 | partitionBy?: TKey | TKey[] | { column: TKey; order?: 'asc' | 'desc' }
|
1948 | ): QueryBuilder<TRecord, TResult2>;
|
1949 | }
|
1950 |
|
1951 | interface GroupBy<TRecord extends {} = any, TResult = unknown[]>
|
1952 | extends RawQueryBuilder<TRecord, TResult>,
|
1953 | ColumnNameQueryBuilder<TRecord, TResult> {}
|
1954 |
|
1955 | interface OrderBy<TRecord extends {} = any, TResult = unknown[]> {
|
1956 | (
|
1957 | columnName: keyof TRecord | QueryBuilder,
|
1958 | order?: 'asc' | 'desc',
|
1959 | nulls?: 'first' | 'last'
|
1960 | ): QueryBuilder<TRecord, TResult>;
|
1961 | (
|
1962 | columnName: string | QueryBuilder,
|
1963 | order?: string,
|
1964 | nulls?: string
|
1965 | ): QueryBuilder<TRecord, TResult>;
|
1966 | (
|
1967 | columnDefs: Array<
|
1968 | | keyof TRecord
|
1969 | | Readonly<{
|
1970 | column: keyof TRecord | QueryBuilder;
|
1971 | order?: 'asc' | 'desc';
|
1972 | nulls?: 'first' | 'last';
|
1973 | }>
|
1974 | >
|
1975 | ): QueryBuilder<TRecord, TResult>;
|
1976 | (
|
1977 | columnDefs: Array<
|
1978 | | string
|
1979 | | Readonly<{
|
1980 | column: string | QueryBuilder;
|
1981 | order?: string;
|
1982 | nulls?: string;
|
1983 | }>
|
1984 | >
|
1985 | ): QueryBuilder<TRecord, TResult>;
|
1986 | }
|
1987 |
|
1988 | interface PartitionBy<TRecord extends {} = any, TResult = unknown[]>
|
1989 | extends OrderBy<TRecord, TResult> {}
|
1990 |
|
1991 | interface Intersect<TRecord extends {} = any, TResult = unknown[]> {
|
1992 | (
|
1993 | callback: MaybeArray<QueryCallback | QueryBuilder<TRecord> | Raw>,
|
1994 | wrap?: boolean
|
1995 | ): QueryBuilder<TRecord, TResult>;
|
1996 | (
|
1997 | ...callbacks: readonly (QueryCallback | Raw | QueryBuilder<TRecord>)[]
|
1998 | ): QueryBuilder<TRecord, TResult>;
|
1999 | }
|
2000 |
|
2001 | interface Except<TRecord extends {} = any, TResult = unknown[]>
|
2002 | extends Intersect<TRecord, TResult> {}
|
2003 |
|
2004 | interface Union<TRecord extends {} = any, TResult = unknown[]>
|
2005 | extends Intersect<TRecord, TResult> {}
|
2006 |
|
2007 | interface Having<TRecord extends {} = any, TResult = unknown[]>
|
2008 | extends WhereWrapped<TRecord, TResult> {
|
2009 | <K extends keyof TRecord>(
|
2010 | column: K,
|
2011 | operator: ComparisonOperator,
|
2012 | value: DbColumn<TRecord[K]>
|
2013 | ): QueryBuilder<TRecord, TResult>;
|
2014 |
|
2015 | (
|
2016 | column: string | Raw,
|
2017 | operator: string,
|
2018 | value: Value | QueryBuilder | null
|
2019 | ): QueryBuilder<TRecord, TResult>;
|
2020 |
|
2021 | (raw: Raw): QueryBuilder<TRecord, TResult>;
|
2022 | }
|
2023 |
|
2024 | interface HavingRange<TRecord extends {} = any, TResult = unknown[]> {
|
2025 | <K extends keyof TRecord>(
|
2026 | columnName: K,
|
2027 | values: readonly DbColumn<TRecord[K]>[]
|
2028 | ): QueryBuilder<TRecord, TResult>;
|
2029 | (columnName: string, values: readonly Value[]): QueryBuilder<
|
2030 | TRecord,
|
2031 | TResult
|
2032 | >;
|
2033 | }
|
2034 |
|
2035 | interface HavingNull<TRecord extends {} = any, TResult = unknown[]> {
|
2036 | (columnName: keyof TRecord): QueryBuilder<TRecord, TResult>;
|
2037 | (columnName: string): QueryBuilder<TRecord, TResult>;
|
2038 | }
|
2039 |
|
2040 |
|
2041 |
|
2042 | interface ColumnNameQueryBuilder<
|
2043 | TRecord extends {} = any,
|
2044 | TResult = unknown[]
|
2045 | > {
|
2046 |
|
2047 |
|
2048 | (columnName: '*'): QueryBuilder<
|
2049 | TRecord,
|
2050 | ArrayIfAlready<TResult, DeferredKeySelection<TRecord, string>>
|
2051 | >;
|
2052 |
|
2053 | <
|
2054 | ColNameUT extends keyof ResolveTableType<TRecord>,
|
2055 | TResult2 = DeferredKeySelection.Augment<
|
2056 | UnwrapArrayMember<TResult>,
|
2057 | ResolveTableType<TRecord>,
|
2058 | ColNameUT & string
|
2059 | >[]
|
2060 | >(
|
2061 | ...columnNames: readonly ColNameUT[]
|
2062 | ): QueryBuilder<TRecord, TResult2>;
|
2063 |
|
2064 | <
|
2065 | ColNameUT extends keyof ResolveTableType<TRecord>,
|
2066 | TResult2 = DeferredKeySelection.Augment<
|
2067 | UnwrapArrayMember<TResult>,
|
2068 | ResolveTableType<TRecord>,
|
2069 | ColNameUT & string
|
2070 | >[]
|
2071 | >(
|
2072 | columnNames: readonly ColNameUT[]
|
2073 | ): QueryBuilder<TRecord, TResult2>;
|
2074 |
|
2075 |
|
2076 |
|
2077 | <
|
2078 | TResult2 = DeferredKeySelection.Augment<
|
2079 | UnwrapArrayMember<TResult>,
|
2080 | SafePartial<TRecord>,
|
2081 | keyof TRecord & string
|
2082 | >[]
|
2083 | >(
|
2084 | ...columnNames: readonly ColumnDescriptor<TRecord, TResult>[]
|
2085 | ): QueryBuilder<TRecord, TResult2>;
|
2086 |
|
2087 | <
|
2088 | TResult2 = DeferredKeySelection.Augment<
|
2089 | UnwrapArrayMember<TResult>,
|
2090 | SafePartial<TRecord>,
|
2091 | keyof TRecord & string
|
2092 | >[]
|
2093 | >(
|
2094 | columnNames: readonly ColumnDescriptor<TRecord, TResult>[]
|
2095 | ): QueryBuilder<TRecord, TResult2>;
|
2096 | }
|
2097 |
|
2098 | type RawBinding = Value | QueryBuilder;
|
2099 |
|
2100 | interface RawQueryBuilder<TRecord extends {} = any, TResult = unknown[]> {
|
2101 | <TResult2 = TResult>(
|
2102 | sql: string,
|
2103 | bindings?: readonly RawBinding[] | ValueDict | RawBinding
|
2104 | ): QueryBuilder<TRecord, TResult2>;
|
2105 | <TResult2 = TResult>(raw: Raw<TResult2>): QueryBuilder<TRecord, TResult2>;
|
2106 | }
|
2107 |
|
2108 |
|
2109 |
|
2110 | interface Raw<TResult = any>
|
2111 | extends events.EventEmitter,
|
2112 | ChainableInterface<ResolveResult<TResult>> {
|
2113 | timeout(ms: number, options?: { cancel?: boolean }): Raw<TResult>;
|
2114 | wrap<TResult2 = TResult>(before: string, after: string): Raw<TResult>;
|
2115 | toSQL(): Sql;
|
2116 | queryContext(context: any): Raw<TResult>;
|
2117 | queryContext(): any;
|
2118 | }
|
2119 |
|
2120 | interface RawBuilder<TRecord extends {} = any, TResult = any> {
|
2121 | <TResult2 = TResult>(value: Value): Raw<TResult2>;
|
2122 | <TResult2 = TResult>(sql: string, binding: RawBinding): Raw<TResult2>;
|
2123 | <TResult2 = TResult>(
|
2124 | sql: string,
|
2125 | bindings: readonly RawBinding[] | ValueDict
|
2126 | ): Raw<TResult2>;
|
2127 | }
|
2128 |
|
2129 | const RefMemberTag: unique symbol;
|
2130 |
|
2131 | interface Ref<TSrc extends string, TMapping extends {}> extends Raw<string> {
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 | [RefMemberTag]: {
|
2144 | src: TSrc;
|
2145 | mapping: TMapping;
|
2146 | };
|
2147 | withSchema(schema: string): this;
|
2148 | as<TAlias extends string>(
|
2149 | alias: TAlias
|
2150 | ): Ref<TSrc, { [K in TAlias]: TSrc }>;
|
2151 | }
|
2152 |
|
2153 | interface RefBuilder {
|
2154 | <TSrc extends string>(src: TSrc): Ref<TSrc, { [K in TSrc]: TSrc }>;
|
2155 | }
|
2156 |
|
2157 | interface BatchInsertBuilder<TRecord extends {} = any, TResult = number[]>
|
2158 | extends Promise<ResolveResult<TResult>> {
|
2159 | transacting(trx: Transaction): this;
|
2160 |
|
2161 | returning(
|
2162 | column: '*'
|
2163 | ): BatchInsertBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
2164 | returning<
|
2165 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
2166 | TResult2 = DeferredKeySelection.Augment<
|
2167 | UnwrapArrayMember<TResult>,
|
2168 | ResolveTableType<TRecord>,
|
2169 | TKey
|
2170 | >[]
|
2171 | >(
|
2172 | column: TKey
|
2173 | ): BatchInsertBuilder<TRecord, TResult2>;
|
2174 | returning<
|
2175 | TKey extends StrKey<ResolveTableType<TRecord>>,
|
2176 | TResult2 = DeferredKeySelection.SetSingle<
|
2177 | DeferredKeySelection.Augment<
|
2178 | UnwrapArrayMember<TResult>,
|
2179 | ResolveTableType<TRecord>,
|
2180 | TKey
|
2181 | >,
|
2182 | false
|
2183 | >[]
|
2184 | >(
|
2185 | columns: readonly TKey[]
|
2186 | ): BatchInsertBuilder<TRecord, TResult2>;
|
2187 |
|
2188 | returning<TResult2 = SafePartial<TRecord>[]>(
|
2189 | column: unknown extends TRecord
|
2190 | ? string | readonly (string | Raw)[] | Raw
|
2191 | : never
|
2192 | ): BatchInsertBuilder<TRecord, TResult2>;
|
2193 | }
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 | type QueryCallback<TRecord extends {} = any, TResult = unknown[]> = (
|
2200 | this: QueryBuilder<TRecord, TResult>,
|
2201 | builder: QueryBuilder<TRecord, TResult>
|
2202 | ) => void;
|
2203 |
|
2204 | type QueryCallbackWithArgs<TRecord extends {} = any, TResult = unknown[]> = (
|
2205 | this: QueryBuilder<TRecord, TResult>,
|
2206 | builder: QueryBuilder<TRecord, TResult>,
|
2207 | ...args: any[]
|
2208 | ) => void;
|
2209 |
|
2210 | interface QueryBuilder<TRecord extends {} = any, TResult = any>
|
2211 | extends QueryInterface<TRecord, TResult>,
|
2212 | ChainableInterface<ResolveResult<TResult>> {
|
2213 | client: Client;
|
2214 | or: QueryBuilder<TRecord, TResult>;
|
2215 | not: QueryBuilder<TRecord, TResult>;
|
2216 | and: QueryBuilder<TRecord, TResult>;
|
2217 |
|
2218 |
|
2219 | columnInfo(
|
2220 | column: keyof DeferredKeySelection.Resolve<TRecord>
|
2221 | ): Promise<ColumnInfo>;
|
2222 | columnInfo(): Promise<
|
2223 | Record<keyof DeferredKeySelection.Resolve<TRecord>, ColumnInfo>
|
2224 | >;
|
2225 |
|
2226 | forUpdate(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
2227 | forUpdate(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
2228 |
|
2229 | forShare(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
2230 | forShare(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
2231 |
|
2232 | forNoKeyUpdate(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
2233 | forNoKeyUpdate(
|
2234 | tableNames: readonly string[]
|
2235 | ): QueryBuilder<TRecord, TResult>;
|
2236 |
|
2237 | forKeyShare(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
2238 | forKeyShare(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
2239 |
|
2240 | skipLocked(): QueryBuilder<TRecord, TResult>;
|
2241 | noWait(): QueryBuilder<TRecord, TResult>;
|
2242 |
|
2243 | toSQL(): Sql;
|
2244 |
|
2245 | on(event: string, callback: Function): QueryBuilder<TRecord, TResult>;
|
2246 |
|
2247 | queryContext(context: any): QueryBuilder<TRecord, TResult>;
|
2248 | queryContext(): any;
|
2249 |
|
2250 | clone(): QueryBuilder<TRecord, TResult>;
|
2251 | timeout(
|
2252 | ms: number,
|
2253 | options?: { cancel?: boolean }
|
2254 | ): QueryBuilder<TRecord, TResult>;
|
2255 | }
|
2256 |
|
2257 | interface Sql {
|
2258 | method: string;
|
2259 | options: any;
|
2260 | bindings: readonly Value[];
|
2261 | sql: string;
|
2262 | toNative(): SqlNative;
|
2263 | }
|
2264 |
|
2265 | interface SqlNative {
|
2266 | bindings: readonly Value[];
|
2267 | sql: string;
|
2268 | }
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 | type ExposedPromiseKeys = 'then' | 'catch' | 'finally';
|
2275 |
|
2276 | interface StringTagSupport {
|
2277 | readonly [Symbol.toStringTag]: string;
|
2278 | }
|
2279 | interface ChainableInterface<T = any>
|
2280 | extends Pick<Promise<T>, keyof Promise<T> & ExposedPromiseKeys>,
|
2281 | StringTagSupport {
|
2282 | generateDdlCommands(): Promise<{
|
2283 | pre: string[];
|
2284 | sql: string[];
|
2285 | check: string | null;
|
2286 | post: string[];
|
2287 | }>;
|
2288 | toQuery(): string;
|
2289 | options(options: Readonly<{ [key: string]: any }>): this;
|
2290 | connection(connection: any): this;
|
2291 | debug(enabled: boolean): this;
|
2292 | transacting(trx: Transaction): this;
|
2293 | stream(handler: (readable: stream.PassThrough) => any): Promise<any>;
|
2294 | stream(
|
2295 | options: Readonly<{ [key: string]: any }>,
|
2296 | handler: (readable: stream.PassThrough) => any
|
2297 | ): Promise<any>;
|
2298 | stream(
|
2299 | options?: Readonly<{ [key: string]: any }>
|
2300 | ): stream.PassThrough & AsyncIterable<ArrayMember<T>>;
|
2301 | pipe<T extends NodeJS.WritableStream>(
|
2302 | writable: T,
|
2303 | options?: Readonly<{ [key: string]: any }>
|
2304 | ): stream.PassThrough;
|
2305 | asCallback(callback: Function): Promise<T>;
|
2306 | }
|
2307 |
|
2308 |
|
2309 | type IsolationLevels =
|
2310 | | 'read uncommitted'
|
2311 | | 'read committed'
|
2312 | | 'snapshot'
|
2313 | | 'repeatable read'
|
2314 | | 'serializable';
|
2315 | interface TransactionConfig {
|
2316 | isolationLevel?: IsolationLevels;
|
2317 | userParams?: Record<string, any>;
|
2318 | doNotRejectOnRollback?: boolean;
|
2319 | connection?: any;
|
2320 | readOnly?: boolean;
|
2321 | }
|
2322 |
|
2323 | interface Transaction<TRecord extends {} = any, TResult = any[]>
|
2324 | extends Knex<TRecord, TResult> {
|
2325 | executionPromise: Promise<TResult>;
|
2326 | parentTransaction?: Transaction;
|
2327 | isCompleted: () => boolean;
|
2328 |
|
2329 | query<TRecord extends {} = any, TResult = void>(
|
2330 | conn: any,
|
2331 | sql: any,
|
2332 | status: any,
|
2333 | value: any
|
2334 | ): QueryBuilder<TRecord, TResult>;
|
2335 | savepoint<T = any>(transactionScope: (trx: Transaction) => any): Promise<T>;
|
2336 | commit(value?: any): QueryBuilder<TRecord, TResult>;
|
2337 | rollback(error?: any): QueryBuilder<TRecord, TResult>;
|
2338 | }
|
2339 |
|
2340 | type TransactionProvider = () => Promise<Transaction>;
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 | interface SchemaBuilder extends ChainableInterface<void> {
|
2347 |
|
2348 | createView(
|
2349 | viewName: string,
|
2350 | callback: (viewBuilder: ViewBuilder) => any
|
2351 | ): SchemaBuilder;
|
2352 | createViewOrReplace(
|
2353 | viewName: string,
|
2354 | callback: (viewBuilder: ViewBuilder) => any
|
2355 | ): SchemaBuilder;
|
2356 | createMaterializedView(
|
2357 | viewName: string,
|
2358 | callback: (viewBuilder: ViewBuilder) => any
|
2359 | ): SchemaBuilder;
|
2360 | refreshMaterializedView(
|
2361 | viewName: string,
|
2362 | concurrently?: boolean
|
2363 | ): SchemaBuilder;
|
2364 | dropView(viewName: string): SchemaBuilder;
|
2365 | dropViewIfExists(viewName: string): SchemaBuilder;
|
2366 | dropMaterializedView(viewName: string): SchemaBuilder;
|
2367 | dropMaterializedViewIfExists(viewName: string): SchemaBuilder;
|
2368 | renameView(oldViewName: string, newViewName: string): SchemaBuilder;
|
2369 | view(
|
2370 | viewName: string,
|
2371 | callback: (viewBuilder: AlterViewBuilder) => any
|
2372 | ): SchemaBuilder;
|
2373 | alterView(
|
2374 | viewName: string,
|
2375 | callback: (tableBuilder: AlterViewBuilder) => any
|
2376 | ): SchemaBuilder;
|
2377 |
|
2378 |
|
2379 | createTable(
|
2380 | tableName: string,
|
2381 | callback: (tableBuilder: CreateTableBuilder) => any
|
2382 | ): SchemaBuilder;
|
2383 | createTableIfNotExists(
|
2384 | tableName: string,
|
2385 | callback: (tableBuilder: CreateTableBuilder) => any
|
2386 | ): SchemaBuilder;
|
2387 | createTableLike(
|
2388 | tableName: string,
|
2389 | tableNameLike: string,
|
2390 | callback?: (tableBuilder: CreateTableBuilder) => any
|
2391 | ): SchemaBuilder;
|
2392 | alterTable(
|
2393 | tableName: string,
|
2394 | callback: (tableBuilder: CreateTableBuilder) => any
|
2395 | ): SchemaBuilder;
|
2396 | renameTable(oldTableName: string, newTableName: string): Promise<void>;
|
2397 | dropTable(tableName: string): SchemaBuilder;
|
2398 | hasTable(tableName: string): Promise<boolean>;
|
2399 | table(
|
2400 | tableName: string,
|
2401 | callback: (tableBuilder: AlterTableBuilder) => any
|
2402 | ): SchemaBuilder;
|
2403 | dropTableIfExists(tableName: string): SchemaBuilder;
|
2404 |
|
2405 |
|
2406 | createSchema(schemaName: string): SchemaBuilder;
|
2407 | createSchemaIfNotExists(schemaName: string): SchemaBuilder;
|
2408 | dropSchema(schemaName: string, cascade?: boolean): SchemaBuilder;
|
2409 | dropSchemaIfExists(schemaName: string, cascade?: boolean): SchemaBuilder;
|
2410 | withSchema(schemaName: string): SchemaBuilder;
|
2411 |
|
2412 |
|
2413 | hasColumn(tableName: string, columnName: string): Promise<boolean>;
|
2414 | raw(statement: string): SchemaBuilder;
|
2415 | queryContext(context: any): SchemaBuilder;
|
2416 | toString(): string;
|
2417 | toSQL(): Sql[];
|
2418 | }
|
2419 |
|
2420 | interface TableBuilder {
|
2421 | increments(
|
2422 | columnName?: string,
|
2423 | options?: { primaryKey?: boolean }
|
2424 | ): ColumnBuilder;
|
2425 | bigIncrements(
|
2426 | columnName?: string,
|
2427 | options?: { primaryKey?: boolean }
|
2428 | ): ColumnBuilder;
|
2429 | dropColumn(columnName: string): TableBuilder;
|
2430 | dropColumns(...columnNames: string[]): TableBuilder;
|
2431 | renameColumn(from: string, to: string): TableBuilder;
|
2432 | integer(columnName: string, length?: number): ColumnBuilder;
|
2433 | tinyint(columnName: string, length?: number): ColumnBuilder;
|
2434 | smallint(columnName: string): ColumnBuilder;
|
2435 | mediumint(columnName: string): ColumnBuilder;
|
2436 | bigint(columnName: string): ColumnBuilder;
|
2437 | bigInteger(columnName: string): ColumnBuilder;
|
2438 | text(columnName: string, textType?: string): ColumnBuilder;
|
2439 | string(columnName: string, length?: number): ColumnBuilder;
|
2440 | float(
|
2441 | columnName: string,
|
2442 | precision?: number,
|
2443 | scale?: number
|
2444 | ): ColumnBuilder;
|
2445 | double(
|
2446 | columnName: string,
|
2447 | precision?: number,
|
2448 | scale?: number
|
2449 | ): ColumnBuilder;
|
2450 | decimal(
|
2451 | columnName: string,
|
2452 | precision?: number | null,
|
2453 | scale?: number
|
2454 | ): ColumnBuilder;
|
2455 | boolean(columnName: string): ColumnBuilder;
|
2456 | date(columnName: string): ColumnBuilder;
|
2457 | dateTime(
|
2458 | columnName: string,
|
2459 | options?: Readonly<{ useTz?: boolean; precision?: number }>
|
2460 | ): ColumnBuilder;
|
2461 | datetime(
|
2462 | columnName: string,
|
2463 | options?: Readonly<{ useTz?: boolean; precision?: number }>
|
2464 | ): ColumnBuilder;
|
2465 | time(columnName: string): ColumnBuilder;
|
2466 | timestamp(
|
2467 | columnName: string,
|
2468 | options?: Readonly<{ useTz?: boolean; precision?: number }>
|
2469 | ): ColumnBuilder;
|
2470 |
|
2471 | timestamp(
|
2472 | columnName: string,
|
2473 | withoutTz?: boolean,
|
2474 | precision?: number
|
2475 | ): ColumnBuilder;
|
2476 | timestamps(
|
2477 | useTimestamps?: boolean,
|
2478 | defaultToNow?: boolean,
|
2479 | useCamelCase?: boolean
|
2480 | ): ColumnBuilder;
|
2481 | timestamps(
|
2482 | options?: Readonly<{
|
2483 | useTimestamps?: boolean;
|
2484 | defaultToNow?: boolean;
|
2485 | useCamelCase?: boolean;
|
2486 | }>
|
2487 | ): void;
|
2488 | geometry(columnName: string): ColumnBuilder;
|
2489 | geography(columnName: string): ColumnBuilder;
|
2490 | point(columnName: string): ColumnBuilder;
|
2491 | binary(columnName: string, length?: number): ColumnBuilder;
|
2492 | enum(
|
2493 | columnName: string,
|
2494 | values: readonly Value[] | null,
|
2495 | options?: EnumOptions
|
2496 | ): ColumnBuilder;
|
2497 | enu(
|
2498 | columnName: string,
|
2499 | values: readonly Value[] | null,
|
2500 | options?: EnumOptions
|
2501 | ): ColumnBuilder;
|
2502 | json(columnName: string): ColumnBuilder;
|
2503 | jsonb(columnName: string): ColumnBuilder;
|
2504 | uuid(
|
2505 | columnName: string,
|
2506 | options?: Readonly<{ useBinaryUuid?: boolean; primaryKey?: boolean }>
|
2507 | ): ColumnBuilder;
|
2508 | comment(val: string): void;
|
2509 | specificType(columnName: string, type: string): ColumnBuilder;
|
2510 | primary(
|
2511 | columnNames: readonly string[],
|
2512 | options?: Readonly<{
|
2513 | constraintName?: string;
|
2514 | deferrable?: deferrableType;
|
2515 | }>
|
2516 | ): TableBuilder;
|
2517 |
|
2518 | primary(
|
2519 | columnNames: readonly string[],
|
2520 | constraintName?: string
|
2521 | ): TableBuilder;
|
2522 | index(
|
2523 | columnNames: string | readonly (string | Raw)[],
|
2524 | indexName?: string,
|
2525 | indexType?: string
|
2526 | ): TableBuilder;
|
2527 | index(
|
2528 | columnNames: string | readonly (string | Raw)[],
|
2529 | indexName?: string,
|
2530 | options?: Readonly<{
|
2531 | indexType?: string;
|
2532 | storageEngineIndexType?: storageEngineIndexType;
|
2533 | predicate?: QueryBuilder;
|
2534 | }>
|
2535 | ): TableBuilder;
|
2536 | setNullable(column: string): TableBuilder;
|
2537 | dropNullable(column: string): TableBuilder;
|
2538 | unique(
|
2539 | columnNames: string | readonly (string | Raw)[],
|
2540 | options?: Readonly<{
|
2541 | indexName?: string;
|
2542 | storageEngineIndexType?: string;
|
2543 | deferrable?: deferrableType;
|
2544 | useConstraint?: boolean;
|
2545 | predicate?: QueryBuilder;
|
2546 | }>
|
2547 | ): TableBuilder;
|
2548 |
|
2549 | unique(
|
2550 | columnNames: string | readonly (string | Raw)[],
|
2551 | indexName?: string
|
2552 | ): TableBuilder;
|
2553 | foreign(column: string, foreignKeyName?: string): ForeignConstraintBuilder;
|
2554 | foreign(
|
2555 | columns: readonly string[],
|
2556 | foreignKeyName?: string
|
2557 | ): MultikeyForeignConstraintBuilder;
|
2558 | check(
|
2559 | checkPredicate: string,
|
2560 | bindings?: Record<string, any>,
|
2561 | constraintName?: string
|
2562 | ): TableBuilder;
|
2563 | dropForeign(
|
2564 | columnNames: string | readonly string[],
|
2565 | foreignKeyName?: string
|
2566 | ): TableBuilder;
|
2567 | dropUnique(
|
2568 | columnNames: readonly (string | Raw)[],
|
2569 | indexName?: string
|
2570 | ): TableBuilder;
|
2571 | dropPrimary(constraintName?: string): TableBuilder;
|
2572 | dropIndex(
|
2573 | columnNames: string | readonly (string | Raw)[],
|
2574 | indexName?: string
|
2575 | ): TableBuilder;
|
2576 | dropTimestamps(useCamelCase?: boolean): TableBuilder;
|
2577 | dropChecks(checkConstraintNames: string | string[]): TableBuilder;
|
2578 | queryContext(context: any): TableBuilder;
|
2579 | }
|
2580 |
|
2581 | interface ViewBuilder<TRecord extends {} = any, TResult = any> {
|
2582 | columns(columns: any): ViewBuilder;
|
2583 | as(selectQuery: QueryBuilder): ViewBuilder;
|
2584 | checkOption(): Promise<void>;
|
2585 | localCheckOption(): Promise<void>;
|
2586 | cascadedCheckOption(): Promise<void>;
|
2587 | queryContext(context: any): ViewBuilder;
|
2588 | }
|
2589 |
|
2590 | interface CreateTableBuilder extends TableBuilder {
|
2591 | engine(val: string): CreateTableBuilder;
|
2592 | charset(val: string): CreateTableBuilder;
|
2593 | collate(val: string): CreateTableBuilder;
|
2594 | inherits(val: string): CreateTableBuilder;
|
2595 | }
|
2596 |
|
2597 | interface AlterTableBuilder extends TableBuilder {}
|
2598 |
|
2599 | interface AlterColumnView extends ViewBuilder {
|
2600 | rename(newName: string): AlterColumnView;
|
2601 | defaultTo(defaultValue: string): AlterColumnView;
|
2602 | }
|
2603 |
|
2604 | interface AlterViewBuilder extends ViewBuilder {
|
2605 | column(column: string): AlterColumnView;
|
2606 | }
|
2607 |
|
2608 | type deferrableType = 'not deferrable' | 'immediate' | 'deferred';
|
2609 | type storageEngineIndexType = 'hash' | 'btree';
|
2610 | type lengthOperator = '>' | '<' | '<=' | '>=' | '!=' | '=';
|
2611 |
|
2612 | interface ColumnBuilder {
|
2613 | index(indexName?: string): ColumnBuilder;
|
2614 | primary(
|
2615 | options?: Readonly<{
|
2616 | constraintName?: string;
|
2617 | deferrable?: deferrableType;
|
2618 | }>
|
2619 | ): ColumnBuilder;
|
2620 |
|
2621 | primary(constraintName?: string): ColumnBuilder;
|
2622 |
|
2623 | unique(
|
2624 | options?: Readonly<{ indexName?: string; deferrable?: deferrableType }>
|
2625 | ): ColumnBuilder;
|
2626 |
|
2627 | unique(indexName?: string): ColumnBuilder;
|
2628 | references(columnName: string): ReferencingColumnBuilder;
|
2629 | defaultTo(value: Value | null, options?: DefaultToOptions): ColumnBuilder;
|
2630 | unsigned(): ColumnBuilder;
|
2631 | notNullable(): ColumnBuilder;
|
2632 | nullable(): ColumnBuilder;
|
2633 | comment(value: string): ColumnBuilder;
|
2634 | alter(
|
2635 | options?: Readonly<{ alterNullable?: boolean; alterType?: boolean }>
|
2636 | ): ColumnBuilder;
|
2637 | queryContext(context: any): ColumnBuilder;
|
2638 | after(columnName: string): ColumnBuilder;
|
2639 | first(): ColumnBuilder;
|
2640 | checkPositive(constraintName?: string): ColumnBuilder;
|
2641 | checkNegative(constraintName?: string): ColumnBuilder;
|
2642 | checkIn(values: string[], constraintName?: string): ColumnBuilder;
|
2643 | checkNotIn(values: string[], constraintName?: string): ColumnBuilder;
|
2644 | checkBetween(
|
2645 | values: any[] | any[][],
|
2646 | constraintName?: string
|
2647 | ): ColumnBuilder;
|
2648 | checkLength(
|
2649 | operator: lengthOperator,
|
2650 | length: number,
|
2651 | constraintName?: string
|
2652 | ): ColumnBuilder;
|
2653 | checkRegex(regex: string, constraintName?: string): ColumnBuilder;
|
2654 | collate(collation: string): ColumnBuilder;
|
2655 | }
|
2656 |
|
2657 | interface ForeignConstraintBuilder {
|
2658 | references(columnName: string): ReferencingColumnBuilder;
|
2659 | }
|
2660 |
|
2661 | interface MultikeyForeignConstraintBuilder {
|
2662 | references(columnNames: readonly string[]): ReferencingColumnBuilder;
|
2663 | }
|
2664 |
|
2665 | interface PostgreSqlColumnBuilder extends ColumnBuilder {
|
2666 | index(
|
2667 | indexName?: string,
|
2668 | options?: Readonly<{ indexType?: string; predicate?: QueryBuilder }>
|
2669 | ): ColumnBuilder;
|
2670 | index(indexName?: string, indexType?: string): ColumnBuilder;
|
2671 | }
|
2672 |
|
2673 | interface SqlLiteColumnBuilder extends ColumnBuilder {
|
2674 | index(
|
2675 | indexName?: string,
|
2676 | options?: Readonly<{ predicate?: QueryBuilder }>
|
2677 | ): ColumnBuilder;
|
2678 | }
|
2679 |
|
2680 | interface MsSqlColumnBuilder extends ColumnBuilder {
|
2681 | index(
|
2682 | indexName?: string,
|
2683 | options?: Readonly<{ predicate?: QueryBuilder }>
|
2684 | ): ColumnBuilder;
|
2685 | }
|
2686 |
|
2687 | interface MySqlColumnBuilder extends ColumnBuilder {
|
2688 | index(
|
2689 | indexName?: string,
|
2690 | options?: Readonly<{
|
2691 | indexType?: string;
|
2692 | storageEngineIndexType?: storageEngineIndexType;
|
2693 | }>
|
2694 | ): ColumnBuilder;
|
2695 | }
|
2696 |
|
2697 |
|
2698 |
|
2699 | type ReferencingColumnBuilder = {
|
2700 | [K in keyof ColumnBuilder]: (
|
2701 | ...args: Parameters<ColumnBuilder[K]>
|
2702 | ) => ReferencingColumnBuilder;
|
2703 | } & {
|
2704 | inTable(tableName: string): ReferencingColumnBuilder;
|
2705 | deferrable(type: deferrableType): ReferencingColumnBuilder;
|
2706 | withKeyName(keyName: string): ReferencingColumnBuilder;
|
2707 | onDelete(command: string): ReferencingColumnBuilder;
|
2708 | onUpdate(command: string): ReferencingColumnBuilder;
|
2709 | };
|
2710 |
|
2711 | interface AlterColumnBuilder extends ColumnBuilder {}
|
2712 |
|
2713 | interface MySqlAlterColumnBuilder extends AlterColumnBuilder {
|
2714 | first(): AlterColumnBuilder;
|
2715 | after(columnName: string): AlterColumnBuilder;
|
2716 | }
|
2717 |
|
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 | interface ColumnInfo {
|
2723 | defaultValue: Value;
|
2724 | type: string;
|
2725 | maxLength: number;
|
2726 | nullable: boolean;
|
2727 | }
|
2728 |
|
2729 | interface Config<SV extends {} = any> {
|
2730 | debug?: boolean;
|
2731 | client?: string | typeof Client;
|
2732 | dialect?: string;
|
2733 | jsonbSupport?: boolean;
|
2734 | version?: string;
|
2735 | connection?: string | StaticConnectionConfig | ConnectionConfigProvider;
|
2736 | pool?: PoolConfig;
|
2737 | migrations?: MigratorConfig;
|
2738 | postProcessResponse?: (result: any, queryContext: any) => any;
|
2739 | wrapIdentifier?: (
|
2740 | value: string,
|
2741 | origImpl: (value: string) => string,
|
2742 | queryContext: any
|
2743 | ) => string;
|
2744 | seeds?: SeederConfig<SV>;
|
2745 | acquireConnectionTimeout?: number;
|
2746 | useNullAsDefault?: boolean;
|
2747 | searchPath?: string | readonly string[];
|
2748 | asyncStackTraces?: boolean;
|
2749 | log?: Logger;
|
2750 | compileSqlOnError?: boolean;
|
2751 | fetchAsString?: string[];
|
2752 | }
|
2753 |
|
2754 | type StaticConnectionConfig =
|
2755 | | ConnectionConfig
|
2756 | | MariaSqlConnectionConfig
|
2757 | | MySqlConnectionConfig
|
2758 | | MySql2ConnectionConfig
|
2759 | | MsSqlConnectionConfig
|
2760 | | OracleDbConnectionConfig
|
2761 | | PgConnectionConfig
|
2762 | | RedshiftConnectionConfig
|
2763 | | Sqlite3ConnectionConfig
|
2764 | | BetterSqlite3ConnectionConfig
|
2765 | | SocketConnectionConfig;
|
2766 |
|
2767 | type ConnectionConfigProvider =
|
2768 | | SyncConnectionConfigProvider
|
2769 | | AsyncConnectionConfigProvider;
|
2770 | type SyncConnectionConfigProvider = () => StaticConnectionConfig;
|
2771 | type AsyncConnectionConfigProvider = () => Promise<StaticConnectionConfig>;
|
2772 |
|
2773 | interface ConnectionConfig {
|
2774 | host: string;
|
2775 | user: string;
|
2776 | password: string;
|
2777 | database: string;
|
2778 | domain?: string;
|
2779 | instanceName?: string;
|
2780 | debug?: boolean;
|
2781 | requestTimeout?: number;
|
2782 | }
|
2783 |
|
2784 | type MsSqlAuthenticationTypeOptions =
|
2785 | | 'default'
|
2786 | | 'ntlm'
|
2787 | | 'azure-active-directory-password'
|
2788 | | 'azure-active-directory-access-token'
|
2789 | | 'azure-active-directory-msi-vm'
|
2790 | | 'azure-active-directory-msi-app-service'
|
2791 | | 'azure-active-directory-service-principal-secret';
|
2792 |
|
2793 | interface MsSqlDefaultAuthenticationConfig extends MsSqlConnectionConfigBase {
|
2794 | type?: 'default' | never;
|
2795 | }
|
2796 |
|
2797 | interface MsSqlAzureActiveDirectoryMsiAppServiceAuthenticationConfig
|
2798 | extends MsSqlConnectionConfigBase {
|
2799 | type: 'azure-active-directory-msi-app-service';
|
2800 | |
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 | clientId?: string;
|
2807 | |
2808 |
|
2809 |
|
2810 | msiEndpoint?: string;
|
2811 | |
2812 |
|
2813 |
|
2814 | msiSecret?: string;
|
2815 | }
|
2816 |
|
2817 | interface MsSqlAzureActiveDirectoryMsiVmAuthenticationConfig
|
2818 | extends MsSqlConnectionConfigBase {
|
2819 | type: 'azure-active-directory-msi-vm';
|
2820 | |
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 | clientId?: string;
|
2827 | |
2828 |
|
2829 |
|
2830 | msiEndpoint?: string;
|
2831 | }
|
2832 |
|
2833 | interface MsSqlAzureActiveDirectoryAccessTokenAuthenticationConfig
|
2834 | extends MsSqlConnectionConfigBase {
|
2835 | type: 'azure-active-directory-access-token';
|
2836 | |
2837 |
|
2838 |
|
2839 | token: string;
|
2840 | }
|
2841 | interface MsSqlAzureActiveDirectoryPasswordAuthenticationConfig
|
2842 | extends MsSqlConnectionConfigBase {
|
2843 | type: 'azure-active-directory-password';
|
2844 | |
2845 |
|
2846 |
|
2847 | domain: string;
|
2848 | userName: string;
|
2849 | password: string;
|
2850 | }
|
2851 |
|
2852 | interface MsSqlAzureActiveDirectoryServicePrincipalSecretConfig
|
2853 | extends MsSqlConnectionConfigBase {
|
2854 | type: 'azure-active-directory-service-principal-secret';
|
2855 | |
2856 |
|
2857 |
|
2858 | clientId: string;
|
2859 | |
2860 |
|
2861 |
|
2862 | clientSecret: string;
|
2863 | |
2864 |
|
2865 |
|
2866 | tenantId: string;
|
2867 | }
|
2868 |
|
2869 | interface MsSqlNtlmAuthenticationConfig extends MsSqlConnectionConfigBase {
|
2870 | type: 'ntlm';
|
2871 | |
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 | domain: string;
|
2877 | userName: string;
|
2878 | password: string;
|
2879 | }
|
2880 |
|
2881 | type MsSqlConnectionConfig =
|
2882 | | MsSqlDefaultAuthenticationConfig
|
2883 | | MsSqlNtlmAuthenticationConfig
|
2884 | | MsSqlAzureActiveDirectoryAccessTokenAuthenticationConfig
|
2885 | | MsSqlAzureActiveDirectoryMsiAppServiceAuthenticationConfig
|
2886 | | MsSqlAzureActiveDirectoryMsiVmAuthenticationConfig
|
2887 | | MsSqlAzureActiveDirectoryPasswordAuthenticationConfig
|
2888 | | MsSqlAzureActiveDirectoryServicePrincipalSecretConfig;
|
2889 |
|
2890 |
|
2891 | interface MsSqlConnectionConfigBase {
|
2892 | type?: MsSqlAuthenticationTypeOptions;
|
2893 |
|
2894 | driver?: string;
|
2895 | userName?: string;
|
2896 | password?: string;
|
2897 | server: string;
|
2898 | port?: number;
|
2899 | domain?: string;
|
2900 | database: string;
|
2901 | connectionTimeout?: number;
|
2902 | requestTimeout?: number;
|
2903 | stream?: boolean;
|
2904 | parseJSON?: boolean;
|
2905 | expirationChecker?(): boolean;
|
2906 | options?: Readonly<{
|
2907 | encrypt?: boolean;
|
2908 | instanceName?: string;
|
2909 | useUTC?: boolean;
|
2910 | tdsVersion?: string;
|
2911 | appName?: string;
|
2912 | abortTransactionOnError?: boolean;
|
2913 | trustedConnection?: boolean;
|
2914 | enableArithAbort?: boolean;
|
2915 | isolationLevel?:
|
2916 | | 'READ_UNCOMMITTED'
|
2917 | | 'READ_COMMITTED'
|
2918 | | 'REPEATABLE_READ'
|
2919 | | 'SERIALIZABLE'
|
2920 | | 'SNAPSHOT';
|
2921 | maxRetriesOnTransientErrors?: number;
|
2922 | multiSubnetFailover?: boolean;
|
2923 | packetSize?: number;
|
2924 | trustServerCertificate?: boolean;
|
2925 | mapBinding?: (value: any) => { value: any; type: any } | undefined;
|
2926 | }>;
|
2927 | pool?: Readonly<{
|
2928 | min?: number;
|
2929 | max?: number;
|
2930 | idleTimeoutMillis?: number;
|
2931 | maxWaitingClients?: number;
|
2932 | testOnBorrow?: boolean;
|
2933 | acquireTimeoutMillis?: number;
|
2934 | fifo?: boolean;
|
2935 | priorityRange?: number;
|
2936 | autostart?: boolean;
|
2937 | evictionRunIntervalMillis?: number;
|
2938 | numTestsPerRun?: number;
|
2939 | softIdleTimeoutMillis?: number;
|
2940 | Promise?: any;
|
2941 | }>;
|
2942 | }
|
2943 |
|
2944 |
|
2945 | interface MariaSqlConnectionConfig {
|
2946 | user?: string;
|
2947 | password?: string;
|
2948 | host?: string;
|
2949 | port?: number;
|
2950 | unixSocket?: string;
|
2951 | protocol?: string;
|
2952 | db?: string;
|
2953 | keepQueries?: boolean;
|
2954 | multiStatements?: boolean;
|
2955 | connTimeout?: number;
|
2956 | pingInterval?: number;
|
2957 | secureAuth?: boolean;
|
2958 | compress?: boolean;
|
2959 | ssl?: boolean | MariaSslConfiguration;
|
2960 | local_infile?: boolean;
|
2961 | read_default_file?: string;
|
2962 | read_default_group?: string;
|
2963 | charset?: string;
|
2964 | streamHWM?: number;
|
2965 | expirationChecker?(): boolean;
|
2966 | }
|
2967 |
|
2968 | interface MariaSslConfiguration {
|
2969 | key?: string;
|
2970 | cert?: string;
|
2971 | ca?: string;
|
2972 | capath?: string;
|
2973 | cipher?: string;
|
2974 | rejectUnauthorized?: boolean;
|
2975 | expirationChecker?(): boolean;
|
2976 | }
|
2977 |
|
2978 |
|
2979 | interface MySqlConnectionConfig {
|
2980 | host?: string;
|
2981 | port?: number;
|
2982 | localAddress?: string;
|
2983 | socketPath?: string;
|
2984 | user?: string;
|
2985 | password?: string;
|
2986 | database?: string;
|
2987 | charset?: string;
|
2988 | timezone?: string;
|
2989 | connectTimeout?: number;
|
2990 | stringifyObjects?: boolean;
|
2991 | insecureAuth?: boolean;
|
2992 | typeCast?: any;
|
2993 | queryFormat?: (query: string, values: any) => string;
|
2994 | supportBigNumbers?: boolean;
|
2995 | bigNumberStrings?: boolean;
|
2996 | dateStrings?: boolean;
|
2997 | debug?: boolean;
|
2998 | trace?: boolean;
|
2999 | multipleStatements?: boolean;
|
3000 | flags?: string;
|
3001 | ssl?: string | MariaSslConfiguration;
|
3002 | decimalNumbers?: boolean;
|
3003 | expirationChecker?(): boolean;
|
3004 | }
|
3005 |
|
3006 |
|
3007 |
|
3008 | interface MySql2ConnectionConfig extends MySqlConnectionConfig {
|
3009 | authPlugins?: {
|
3010 | [pluginName: string]: (pluginMetadata: any) => (pluginData: any) => any;
|
3011 | };
|
3012 | authSwitchHandler?: (data: any, callback: () => void) => any;
|
3013 | charsetNumber?: number;
|
3014 | compress?: boolean;
|
3015 | connectAttributes?: { [attrNames: string]: any };
|
3016 | enableKeepAlive?: boolean;
|
3017 | keepAliveInitialDelay?: number;
|
3018 | maxPreparedStatements?: number;
|
3019 | namedPlaceholders?: boolean;
|
3020 | nestTables?: boolean | string;
|
3021 | passwordSha1?: string;
|
3022 | rowsAsArray?: boolean;
|
3023 | stream?: boolean | ((opts: any) => Stream) | Stream;
|
3024 | uri?: string;
|
3025 | }
|
3026 |
|
3027 | interface OracleDbConnectionConfig {
|
3028 | host: string;
|
3029 | user: string;
|
3030 | password?: string;
|
3031 | database?: string;
|
3032 | domain?: string;
|
3033 | instanceName?: string;
|
3034 | debug?: boolean;
|
3035 | requestTimeout?: number;
|
3036 | connectString?: string;
|
3037 | expirationChecker?(): boolean;
|
3038 | }
|
3039 |
|
3040 | // Config object for pg: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg/index.d.ts
|
3041 | interface PgConnectionConfig {
|
3042 | user?: string;
|
3043 | database?: string;
|
3044 | password?: string | (() => string | Promise<string>);
|
3045 | port?: number;
|
3046 | host?: string;
|
3047 | connectionString?: string;
|
3048 | keepAlive?: boolean;
|
3049 | stream?: () => stream.Duplex | stream.Duplex | undefined;
|
3050 | statement_timeout?: false | number;
|
3051 | parseInputDatesAsUTC?: boolean;
|
3052 | ssl?: boolean | ConnectionOptions;
|
3053 | query_timeout?: number;
|
3054 | keepAliveInitialDelayMillis?: number;
|
3055 | idle_in_transaction_session_timeout?: number;
|
3056 | application_name?: string;
|
3057 | connectionTimeoutMillis?: number;
|
3058 | types?: PgCustomTypesConfig;
|
3059 | options?: string;
|
3060 | expirationChecker?(): boolean;
|
3061 | }
|
3062 |
|
3063 | type PgGetTypeParser = (oid: number, format: string) => any;
|
3064 |
|
3065 | interface PgCustomTypesConfig {
|
3066 | getTypeParser: PgGetTypeParser;
|
3067 | }
|
3068 |
|
3069 | type RedshiftConnectionConfig = PgConnectionConfig;
|
3070 |
|
3071 |
|
3072 | interface Sqlite3ConnectionConfig {
|
3073 | filename: string;
|
3074 | flags?: string[];
|
3075 | debug?: boolean;
|
3076 | expirationChecker?(): boolean;
|
3077 | }
|
3078 |
|
3079 |
|
3080 | interface BetterSqlite3ConnectionConfig {
|
3081 | filename: string;
|
3082 | options?: {
|
3083 | nativeBinding?: string;
|
3084 | readonly?: boolean;
|
3085 | };
|
3086 | }
|
3087 |
|
3088 | interface SocketConnectionConfig {
|
3089 | socketPath: string;
|
3090 | user: string;
|
3091 | password: string;
|
3092 | database: string;
|
3093 | debug?: boolean;
|
3094 | expirationChecker?(): boolean;
|
3095 | }
|
3096 |
|
3097 | interface PoolConfig {
|
3098 | name?: string;
|
3099 | afterCreate?: Function;
|
3100 | min?: number;
|
3101 | max?: number;
|
3102 | refreshIdle?: boolean;
|
3103 | idleTimeoutMillis?: number;
|
3104 | reapIntervalMillis?: number;
|
3105 | returnToHead?: boolean;
|
3106 | priorityRange?: number;
|
3107 | log?: (message: string, logLevel: string) => void;
|
3108 |
|
3109 |
|
3110 | propagateCreateError?: boolean;
|
3111 | createRetryIntervalMillis?: number;
|
3112 | createTimeoutMillis?: number;
|
3113 | destroyTimeoutMillis?: number;
|
3114 | acquireTimeoutMillis?: number;
|
3115 | }
|
3116 |
|
3117 | type LogFn = (message: any) => void;
|
3118 |
|
3119 | interface Logger {
|
3120 | warn?: LogFn;
|
3121 | error?: LogFn;
|
3122 | debug?: LogFn;
|
3123 | inspectionDepth?: number;
|
3124 | enableColors?: boolean;
|
3125 | deprecate?: (method: string, alternative: string) => void;
|
3126 | }
|
3127 |
|
3128 | interface Migration {
|
3129 | up: (knex: Knex) => PromiseLike<any>;
|
3130 | down?: (knex: Knex) => PromiseLike<any>;
|
3131 | }
|
3132 |
|
3133 | interface MigrationSource<TMigrationSpec> {
|
3134 | getMigrations(loadExtensions: readonly string[]): Promise<TMigrationSpec[]>;
|
3135 | getMigrationName(migration: TMigrationSpec): string;
|
3136 | getMigration(migration: TMigrationSpec): Promise<Migration>;
|
3137 | }
|
3138 |
|
3139 | interface MigratorConfig {
|
3140 | database?: string;
|
3141 | directory?: string | readonly string[];
|
3142 | extension?: string;
|
3143 | stub?: string;
|
3144 | tableName?: string;
|
3145 | schemaName?: string;
|
3146 | disableTransactions?: boolean;
|
3147 | disableMigrationsListValidation?: boolean;
|
3148 | sortDirsSeparately?: boolean;
|
3149 | loadExtensions?: readonly string[];
|
3150 | migrationSource?: MigrationSource<unknown>;
|
3151 | name?: string;
|
3152 | }
|
3153 |
|
3154 | interface Migrator {
|
3155 | make(name: string, config?: MigratorConfig): Promise<string>;
|
3156 | latest(config?: MigratorConfig): Promise<any>;
|
3157 | rollback(config?: MigratorConfig, all?: boolean): Promise<any>;
|
3158 | status(config?: MigratorConfig): Promise<number>;
|
3159 | currentVersion(config?: MigratorConfig): Promise<string>;
|
3160 | list(config?: MigratorConfig): Promise<any>;
|
3161 | up(config?: MigratorConfig): Promise<any>;
|
3162 | down(config?: MigratorConfig): Promise<any>;
|
3163 | forceFreeMigrationsLock(config?: MigratorConfig): Promise<any>;
|
3164 | }
|
3165 |
|
3166 | interface Seed {
|
3167 | seed: (knex: Knex) => PromiseLike<void>;
|
3168 | }
|
3169 |
|
3170 | interface SeedSource<TSeedSpec> {
|
3171 | getSeeds(config: SeederConfig): Promise<TSeedSpec[]>;
|
3172 | getSeed(seed: TSeedSpec): Promise<Seed>;
|
3173 | }
|
3174 |
|
3175 | interface SeederConfig<V extends {} = any> {
|
3176 | extension?: string;
|
3177 | directory?: string | readonly string[];
|
3178 | loadExtensions?: readonly string[];
|
3179 | specific?: string;
|
3180 | timestampFilenamePrefix?: boolean;
|
3181 | recursive?: boolean;
|
3182 | sortDirsSeparately?: boolean;
|
3183 | stub?: string;
|
3184 | variables?: V;
|
3185 | seedSource?: SeedSource<unknown>;
|
3186 | }
|
3187 |
|
3188 | class Seeder {
|
3189 | constructor(knex: Knex);
|
3190 | setConfig(config: SeederConfig): SeederConfig;
|
3191 | run(config?: SeederConfig): Promise<[string[]]>;
|
3192 | make(name: string, config?: SeederConfig): Promise<string>;
|
3193 | }
|
3194 |
|
3195 | interface FunctionHelper {
|
3196 | now(precision?: number): Raw;
|
3197 | uuid(): Raw;
|
3198 | uuidToBin(uuid: string, ordered?: boolean): Buffer;
|
3199 | binToUuid(bin: Buffer, ordered?: boolean): string;
|
3200 | }
|
3201 |
|
3202 | interface EnumOptions {
|
3203 | useNative: boolean;
|
3204 | existingType?: boolean;
|
3205 | schemaName?: string;
|
3206 | enumName: string;
|
3207 | }
|
3208 |
|
3209 | interface DefaultToOptions {
|
3210 |
|
3211 | constraintName?: string;
|
3212 | }
|
3213 |
|
3214 | class Client extends events.EventEmitter {
|
3215 | constructor(config: Config);
|
3216 | config: Config;
|
3217 | dialect: string;
|
3218 | driverName: string;
|
3219 | connectionSettings: object;
|
3220 |
|
3221 | acquireRawConnection(): Promise<any>;
|
3222 | destroyRawConnection(connection: any): Promise<void>;
|
3223 | validateConnection(connection: any): Promise<boolean>;
|
3224 | logger: Logger;
|
3225 | version?: string;
|
3226 | connectionConfigProvider: any;
|
3227 | connectionConfigExpirationChecker: null | (() => boolean);
|
3228 | valueForUndefined: any;
|
3229 | formatter(builder: any): any;
|
3230 | queryBuilder(): QueryBuilder;
|
3231 | queryCompiler(builder: any): any;
|
3232 | schemaBuilder(): SchemaBuilder;
|
3233 | schemaCompiler(builder: SchemaBuilder): any;
|
3234 | tableBuilder(
|
3235 | type: any,
|
3236 | tableName: any,
|
3237 | tableNameLike: any,
|
3238 | fn: any
|
3239 | ): TableBuilder;
|
3240 | tableCompiler(tableBuilder: any): any;
|
3241 | columnBuilder(tableBuilder: any, type: any, args: any): ColumnBuilder;
|
3242 | columnCompiler(tableBuilder: any, columnBuilder: any): any;
|
3243 | runner(builder: any): any;
|
3244 | transaction(container: any, config: any, outerTx: any): Transaction;
|
3245 | raw(...args: any[]): any;
|
3246 | ref(...args: any[]): Ref<any, any>;
|
3247 | query(connection: any, obj: any): any;
|
3248 | stream(connection: any, obj: any, stream: any, options: any): any;
|
3249 | prepBindings(bindings: any): any;
|
3250 | positionBindings(sql: any): any;
|
3251 | postProcessResponse(resp: any, queryContext: any): any;
|
3252 | wrapIdentifier(value: any, queryContext: any): any;
|
3253 | customWrapIdentifier(value: any, origImpl: any, queryContext: any): any;
|
3254 | wrapIdentifierImpl(value: any): string;
|
3255 | initializeDriver(): void;
|
3256 | driver: any;
|
3257 | poolDefaults(): {
|
3258 | min: number;
|
3259 | max: number;
|
3260 | propagateCreateError: boolean;
|
3261 | };
|
3262 | getPoolSettings(poolConfig: any): any;
|
3263 | initializePool(config?: {}): void;
|
3264 | pool: tarn.Pool<any> | undefined;
|
3265 | acquireConnection(): any;
|
3266 | releaseConnection(connection: any): any;
|
3267 | destroy(callback: any): any;
|
3268 | database(): any;
|
3269 | canCancelQuery: boolean;
|
3270 | assertCanCancelQuery(): void;
|
3271 | cancelQuery(): void;
|
3272 | }
|
3273 | }
|
3274 |
|
3275 | export = knex;
|