knex 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/bin/cli.js +0 -0
- package/lib/dialects/cockroachdb/crdb-columncompiler.js +14 -0
- package/lib/dialects/cockroachdb/index.js +5 -0
- package/lib/dialects/postgres/schema/pg-columncompiler.js +7 -1
- package/lib/dialects/postgres/schema/pg-tablecompiler.js +33 -6
- package/lib/dialects/sqlite3/index.js +10 -1
- package/lib/dialects/sqlite3/query/sqlite-querycompiler.js +1 -1
- package/lib/execution/runner.js +2 -9
- package/lib/knex-builder/internal/parse-connection.js +4 -2
- package/lib/schema/columncompiler.js +4 -2
- package/package.json +6 -6
- package/types/index.d.ts +813 -410
package/types/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ import ResultTypes = require('./result');
|
|
|
13
13
|
|
|
14
14
|
import { Tables } from './tables';
|
|
15
15
|
|
|
16
|
-
import { ConnectionOptions } from
|
|
17
|
-
import { Stream } from
|
|
16
|
+
import { ConnectionOptions } from 'tls';
|
|
17
|
+
import { Stream } from 'stream';
|
|
18
18
|
|
|
19
19
|
// # Generic type-level utilities
|
|
20
20
|
|
|
@@ -30,9 +30,10 @@ type StrKey<T> = string & keyof T;
|
|
|
30
30
|
|
|
31
31
|
// If T is unknown then convert to any, else retain original
|
|
32
32
|
type UnknownToAny<T> = unknown extends T ? any : T;
|
|
33
|
-
type CurlyCurlyToAny<T> = T extends unknown
|
|
34
|
-
(<U>() => U extends T ? 0 : 1) extends
|
|
35
|
-
|
|
33
|
+
type CurlyCurlyToAny<T> = T extends unknown // distribute
|
|
34
|
+
? (<U>() => U extends T ? 0 : 1) extends <U>() => U extends {} ? 0 : 1
|
|
35
|
+
? any
|
|
36
|
+
: T
|
|
36
37
|
: never;
|
|
37
38
|
type UnknownOrCurlyCurlyToAny<T> = [UnknownToAny<T> | CurlyCurlyToAny<T>][0];
|
|
38
39
|
type AnyToUnknown<T> = unknown extends T ? unknown : T;
|
|
@@ -42,8 +43,8 @@ type AnyOrUnknownToOther<T1, T2> = unknown extends T1 ? T2 : T1;
|
|
|
42
43
|
// This is primarily to keep the signatures more intuitive.
|
|
43
44
|
type AugmentParams<TTarget, TParams> = TParams extends {}
|
|
44
45
|
? keyof TParams extends never
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
? TTarget
|
|
47
|
+
: {} & TTarget & TParams
|
|
47
48
|
: TTarget;
|
|
48
49
|
|
|
49
50
|
// Check if provided keys (expressed as a single or union type) are members of TBase
|
|
@@ -52,9 +53,9 @@ type AreKeysOf<TBase, TKeys> = Boxed<TKeys> extends Boxed<keyof TBase>
|
|
|
52
53
|
: false;
|
|
53
54
|
|
|
54
55
|
// https://stackoverflow.com/a/50375286/476712
|
|
55
|
-
type UnionToIntersection<U> = (U extends any
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
57
|
+
k: infer I
|
|
58
|
+
) => void
|
|
58
59
|
? I
|
|
59
60
|
: never;
|
|
60
61
|
|
|
@@ -89,8 +90,8 @@ type PartialOrAny<TBase, TKeys> = Boxed<TKeys> extends Boxed<never>
|
|
|
89
90
|
// to facilitates type-safe aliasing for object syntax
|
|
90
91
|
type MappedAliasType<TBase, TAliasMapping> = {} & {
|
|
91
92
|
[K in keyof TAliasMapping]: TAliasMapping[K] extends keyof TBase
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
? TBase[TAliasMapping[K]]
|
|
94
|
+
: any;
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
// Container type for situations when we want a partial/intersection eventually
|
|
@@ -117,17 +118,17 @@ type DeferredKeySelection<
|
|
|
117
118
|
TIntersectProps extends {} = {},
|
|
118
119
|
// Extra props which will be unioned with the result
|
|
119
120
|
TUnionProps = never
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
> = {
|
|
122
|
+
// These properties are not actually used, but exist simply because
|
|
123
|
+
// typescript doesn't end up happy when type parameters are unused
|
|
124
|
+
_base: TBase;
|
|
125
|
+
_hasSelection: THasSelect;
|
|
126
|
+
_keys: TKeys;
|
|
127
|
+
_aliases: TAliasMapping;
|
|
128
|
+
_single: TSingle;
|
|
129
|
+
_intersectProps: TIntersectProps;
|
|
130
|
+
_unionProps: TUnionProps;
|
|
131
|
+
};
|
|
131
132
|
|
|
132
133
|
// An companion namespace for DeferredKeySelection which provides type operators
|
|
133
134
|
// to build up participants of intersection/partial over multiple invocations
|
|
@@ -149,7 +150,15 @@ declare namespace DeferredKeySelection {
|
|
|
149
150
|
infer TIntersectProps,
|
|
150
151
|
infer TUnionProps
|
|
151
152
|
>
|
|
152
|
-
? DeferredKeySelection<
|
|
153
|
+
? DeferredKeySelection<
|
|
154
|
+
TBase,
|
|
155
|
+
TKeys,
|
|
156
|
+
THasSelect,
|
|
157
|
+
TAliasMapping,
|
|
158
|
+
TSingle,
|
|
159
|
+
TIntersectProps,
|
|
160
|
+
TUnionProps
|
|
161
|
+
>
|
|
153
162
|
: DeferredKeySelection<TBase, never>;
|
|
154
163
|
|
|
155
164
|
// If TSelection is already a deferred selection, then replace the base with TBase
|
|
@@ -158,47 +167,68 @@ declare namespace DeferredKeySelection {
|
|
|
158
167
|
//
|
|
159
168
|
// For practical reasons applicable to current context, we always return arrays of
|
|
160
169
|
// deferred selections. So, this particular operator may not be useful in generic contexts.
|
|
161
|
-
type ReplaceBase<TSelection, TBase> =
|
|
162
|
-
TSelection
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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;
|
|
168
179
|
|
|
169
180
|
// Type operators to substitute individual type parameters:
|
|
170
181
|
|
|
171
182
|
type SetSingle<
|
|
172
183
|
TSelection,
|
|
173
184
|
TSingle extends boolean
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
? DeferredKeySelection<
|
|
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
|
+
>
|
|
184
203
|
: never;
|
|
185
204
|
|
|
186
205
|
type AddKey<
|
|
187
206
|
TSelection,
|
|
188
207
|
TKey extends string
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
? DeferredKeySelection<
|
|
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
|
+
>
|
|
199
226
|
: DeferredKeySelection<unknown, TKey, true>;
|
|
200
227
|
|
|
201
|
-
type AddAliases<
|
|
228
|
+
type AddAliases<
|
|
229
|
+
TSelection,
|
|
230
|
+
T extends {}
|
|
231
|
+
> = TSelection extends DeferredKeySelection<
|
|
202
232
|
infer TBase,
|
|
203
233
|
infer TKeys,
|
|
204
234
|
infer THasSelect,
|
|
@@ -207,7 +237,15 @@ declare namespace DeferredKeySelection {
|
|
|
207
237
|
infer TIntersectProps,
|
|
208
238
|
infer TUnionProps
|
|
209
239
|
>
|
|
210
|
-
? DeferredKeySelection<
|
|
240
|
+
? DeferredKeySelection<
|
|
241
|
+
TBase,
|
|
242
|
+
TKeys,
|
|
243
|
+
THasSelect,
|
|
244
|
+
TAliasMapping & T,
|
|
245
|
+
TSingle,
|
|
246
|
+
TIntersectProps,
|
|
247
|
+
TUnionProps
|
|
248
|
+
>
|
|
211
249
|
: DeferredKeySelection<unknown, never, false, T>;
|
|
212
250
|
|
|
213
251
|
type AddUnionMember<TSelection, T> = TSelection extends DeferredKeySelection<
|
|
@@ -219,15 +257,25 @@ declare namespace DeferredKeySelection {
|
|
|
219
257
|
infer TIntersectProps,
|
|
220
258
|
infer TUnionProps
|
|
221
259
|
>
|
|
222
|
-
? DeferredKeySelection<
|
|
260
|
+
? DeferredKeySelection<
|
|
261
|
+
TBase,
|
|
262
|
+
TKeys,
|
|
263
|
+
THasSelect,
|
|
264
|
+
TAliasMapping,
|
|
265
|
+
TSingle,
|
|
266
|
+
TIntersectProps,
|
|
267
|
+
TUnionProps | T
|
|
268
|
+
>
|
|
223
269
|
: DeferredKeySelection<TSelection, never, false, {}, false, {}, T>;
|
|
224
270
|
|
|
225
271
|
// Convenience utility to set base, keys and aliases in a single type
|
|
226
272
|
// application
|
|
227
|
-
type Augment<
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
273
|
+
type Augment<
|
|
274
|
+
T,
|
|
275
|
+
TBase,
|
|
276
|
+
TKey extends string,
|
|
277
|
+
TAliasMapping extends {} = {}
|
|
278
|
+
> = AddAliases<AddKey<SetBase<T, TBase>, TKey>, TAliasMapping>;
|
|
231
279
|
|
|
232
280
|
// Core resolution logic -- Refer to docs for DeferredKeySelection for specifics
|
|
233
281
|
type ResolveOne<TSelection> = TSelection extends DeferredKeySelection<
|
|
@@ -240,27 +288,30 @@ declare namespace DeferredKeySelection {
|
|
|
240
288
|
infer TUnionProps
|
|
241
289
|
>
|
|
242
290
|
? UnknownOrCurlyCurlyToAny<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
291
|
+
// ^ We convert final result to any if it is unknown for backward compatibility.
|
|
292
|
+
// Historically knex typings have been liberal with returning any and changing
|
|
293
|
+
// default return type to unknown would be a major breaking change for users.
|
|
294
|
+
//
|
|
295
|
+
// So we compromise on type safety here and return any.
|
|
296
|
+
| AugmentParams<
|
|
297
|
+
AnyToUnknown<TBase> extends {}
|
|
298
|
+
? // ^ Conversion of any -> unknown is needed here to prevent distribution
|
|
299
|
+
// of any over the conditional
|
|
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
|
+
>
|
|
264
315
|
: TSelection;
|
|
265
316
|
|
|
266
317
|
type Resolve<TSelection> = TSelection extends DeferredKeySelection.Any
|
|
@@ -272,7 +323,10 @@ declare namespace DeferredKeySelection {
|
|
|
272
323
|
: UnknownOrCurlyCurlyToAny<Knex.ResolveTableType<TSelection>>;
|
|
273
324
|
}
|
|
274
325
|
|
|
275
|
-
type AggregationQueryResult<
|
|
326
|
+
type AggregationQueryResult<
|
|
327
|
+
TResult,
|
|
328
|
+
TIntersectProps2 extends {}
|
|
329
|
+
> = ArrayIfAlready<
|
|
276
330
|
TResult,
|
|
277
331
|
UnwrapArrayMember<TResult> extends DeferredKeySelection<
|
|
278
332
|
infer TBase,
|
|
@@ -283,10 +337,18 @@ type AggregationQueryResult<TResult, TIntersectProps2 extends {}> = ArrayIfAlrea
|
|
|
283
337
|
infer TIntersectProps,
|
|
284
338
|
infer TUnionProps
|
|
285
339
|
>
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
|
290
352
|
>;
|
|
291
353
|
|
|
292
354
|
// If we have more categories of deferred selection in future,
|
|
@@ -298,7 +360,7 @@ type ResolveResult<S> = DeferredKeySelection.Resolve<S>;
|
|
|
298
360
|
type Callback = Function;
|
|
299
361
|
type Client = Function;
|
|
300
362
|
|
|
301
|
-
type Dict<T = any> = { [k: string]: T
|
|
363
|
+
type Dict<T = any> = { [k: string]: T };
|
|
302
364
|
|
|
303
365
|
type SafePick<T, K extends keyof T> = T extends {} ? Pick<T, K> : any;
|
|
304
366
|
|
|
@@ -313,12 +375,19 @@ interface DMLOptions {
|
|
|
313
375
|
}
|
|
314
376
|
|
|
315
377
|
export interface Knex<TRecord extends {} = any, TResult = any[]>
|
|
316
|
-
extends Knex.QueryInterface<TRecord, TResult>,
|
|
378
|
+
extends Knex.QueryInterface<TRecord, TResult>,
|
|
379
|
+
events.EventEmitter {
|
|
317
380
|
<TTable extends Knex.TableNames>(
|
|
318
381
|
tableName: TTable,
|
|
319
382
|
options?: TableOptions
|
|
320
|
-
): Knex.QueryBuilder<
|
|
321
|
-
|
|
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
|
+
>(
|
|
322
391
|
tableName?: Knex.TableDescriptor | Knex.AliasDict,
|
|
323
392
|
options?: TableOptions
|
|
324
393
|
): Knex.QueryBuilder<TRecord2, TResult2>;
|
|
@@ -330,9 +399,7 @@ export interface Knex<TRecord extends {} = any, TResult = any[]>
|
|
|
330
399
|
transactionProvider(
|
|
331
400
|
config?: Knex.TransactionConfig
|
|
332
401
|
): Knex.TransactionProvider;
|
|
333
|
-
transaction(
|
|
334
|
-
config?: Knex.TransactionConfig
|
|
335
|
-
): Promise<Knex.Transaction>;
|
|
402
|
+
transaction(config?: Knex.TransactionConfig): Promise<Knex.Transaction>;
|
|
336
403
|
transaction(
|
|
337
404
|
transactionScope?: null,
|
|
338
405
|
config?: Knex.TransactionConfig
|
|
@@ -350,14 +417,14 @@ export interface Knex<TRecord extends {} = any, TResult = any[]>
|
|
|
350
417
|
data: TRecord2 extends Knex.CompositeTableType<unknown>
|
|
351
418
|
? ReadonlyArray<Knex.ResolveTableType<TRecord2, 'insert'>>
|
|
352
419
|
: ReadonlyArray<Knex.DbRecordArr<TRecord2>>,
|
|
353
|
-
chunkSize?: number
|
|
420
|
+
chunkSize?: number
|
|
354
421
|
): Knex.BatchInsertBuilder<TRecord2, TResult2>;
|
|
355
422
|
|
|
356
423
|
schema: Knex.SchemaBuilder;
|
|
357
|
-
queryBuilder<
|
|
358
|
-
TRecord2,
|
|
359
|
-
TResult2
|
|
360
|
-
>;
|
|
424
|
+
queryBuilder<
|
|
425
|
+
TRecord2 extends {} = TRecord,
|
|
426
|
+
TResult2 = TResult
|
|
427
|
+
>(): Knex.QueryBuilder<TRecord2, TResult2>;
|
|
361
428
|
|
|
362
429
|
client: any;
|
|
363
430
|
migrate: Knex.Migrator;
|
|
@@ -380,44 +447,37 @@ export declare namespace knex {
|
|
|
380
447
|
fn: <TRecord extends {} = any, TResult = unknown[]>(
|
|
381
448
|
this: Knex.QueryBuilder<TRecord, TResult>,
|
|
382
449
|
...args: any[]
|
|
383
|
-
) =>
|
|
450
|
+
) =>
|
|
451
|
+
| Knex.QueryBuilder<TRecord, TResult>
|
|
452
|
+
| Promise<
|
|
453
|
+
| Knex.QueryBuilder<TRecord | TResult>
|
|
454
|
+
| DeferredKeySelection.Resolve<TResult>
|
|
455
|
+
>
|
|
384
456
|
): void;
|
|
385
457
|
}
|
|
386
458
|
|
|
387
459
|
class TableBuilder {
|
|
388
|
-
static extend(
|
|
460
|
+
static extend<T = Knex.TableBuilder, B = Knex.TableBuilder>(
|
|
389
461
|
methodName: string,
|
|
390
|
-
fn: (
|
|
391
|
-
this: Knex.TableBuilder,
|
|
392
|
-
...args: any[]
|
|
393
|
-
) => Knex.TableBuilder
|
|
462
|
+
fn: (this: T, ...args: any[]) => B
|
|
394
463
|
): void;
|
|
395
464
|
}
|
|
396
465
|
class ViewBuilder {
|
|
397
|
-
static extend(
|
|
466
|
+
static extend<T = Knex.ViewBuilder, B = Knex.ViewBuilder>(
|
|
398
467
|
methodName: string,
|
|
399
|
-
fn: (
|
|
400
|
-
this: Knex.ViewBuilder,
|
|
401
|
-
...args: any[]
|
|
402
|
-
) => Knex.ViewBuilder
|
|
468
|
+
fn: (this: T, ...args: any[]) => B
|
|
403
469
|
): void;
|
|
404
470
|
}
|
|
405
471
|
class SchemaBuilder {
|
|
406
|
-
static extend(
|
|
472
|
+
static extend<T = Knex.SchemaBuilder, B = Knex.SchemaBuilder>(
|
|
407
473
|
methodName: string,
|
|
408
|
-
fn: (
|
|
409
|
-
this: Knex.SchemaBuilder,
|
|
410
|
-
...args: any[]
|
|
411
|
-
) => Knex.SchemaBuilder
|
|
474
|
+
fn: (this: T, ...args: any[]) => B
|
|
412
475
|
): void;
|
|
413
476
|
}
|
|
414
477
|
class ColumnBuilder {
|
|
415
|
-
static extend(
|
|
478
|
+
static extend<T = Knex.ColumnBuilder, B = Knex.ColumnBuilder>(
|
|
416
479
|
methodName: string,
|
|
417
|
-
fn: (
|
|
418
|
-
this: Knex.ColumnBuilder,
|
|
419
|
-
...args: any[]
|
|
420
|
-
) => Knex.ColumnBuilder
|
|
480
|
+
fn: (this: T, ...args: any[]) => B
|
|
421
481
|
): void;
|
|
422
482
|
}
|
|
423
483
|
|
|
@@ -442,6 +502,7 @@ export declare namespace Knex {
|
|
|
442
502
|
| Array<Date>
|
|
443
503
|
| Array<boolean>
|
|
444
504
|
| Buffer
|
|
505
|
+
| object
|
|
445
506
|
| Knex.Raw;
|
|
446
507
|
|
|
447
508
|
interface ValueDict extends Dict<Value | Knex.QueryBuilder> {}
|
|
@@ -460,15 +521,16 @@ export declare namespace Knex {
|
|
|
460
521
|
|
|
461
522
|
type TableDescriptor = string | Knex.Raw | Knex.QueryBuilder;
|
|
462
523
|
|
|
463
|
-
type Lookup<
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
TDefault
|
|
524
|
+
type Lookup<
|
|
525
|
+
TRegistry extends {},
|
|
526
|
+
TKey extends string,
|
|
527
|
+
TDefault = never
|
|
528
|
+
> = TKey extends keyof TRegistry ? TRegistry[TKey] : TDefault;
|
|
467
529
|
|
|
468
530
|
type MaybeRawColumn<TColumn> = TColumn | Raw<TColumn>;
|
|
469
531
|
|
|
470
532
|
type MaybeRawRecord<TRecord> = {
|
|
471
|
-
[K in keyof TRecord]: MaybeRawColumn<TRecord[K]
|
|
533
|
+
[K in keyof TRecord]: MaybeRawColumn<TRecord[K]>;
|
|
472
534
|
};
|
|
473
535
|
|
|
474
536
|
type DbColumn<TColumn> = Readonly<MaybeRawColumn<TColumn>>;
|
|
@@ -477,11 +539,16 @@ export declare namespace Knex {
|
|
|
477
539
|
|
|
478
540
|
type DbRecordArr<TRecord> = Readonly<MaybeArray<DbRecord<TRecord>>>;
|
|
479
541
|
|
|
480
|
-
export type CompositeTableType<
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
542
|
+
export type CompositeTableType<
|
|
543
|
+
TBase,
|
|
544
|
+
TInsert = TBase,
|
|
545
|
+
TUpdate = Partial<TInsert>,
|
|
546
|
+
TUpsert = Partial<TInsert>
|
|
547
|
+
> = {
|
|
548
|
+
base: TBase;
|
|
549
|
+
insert: TInsert;
|
|
550
|
+
update: TUpdate;
|
|
551
|
+
upsert: TUpsert;
|
|
485
552
|
};
|
|
486
553
|
|
|
487
554
|
type TableNames = keyof Tables;
|
|
@@ -490,20 +557,40 @@ export declare namespace Knex {
|
|
|
490
557
|
|
|
491
558
|
type TableType<TTable extends keyof Tables> = Tables[TTable];
|
|
492
559
|
|
|
493
|
-
type ResolveTableType<
|
|
560
|
+
type ResolveTableType<
|
|
561
|
+
TCompositeTableType,
|
|
562
|
+
TScope extends TableInterfaceScope = 'base'
|
|
563
|
+
> = TCompositeTableType extends CompositeTableType<unknown>
|
|
494
564
|
? TCompositeTableType[TScope]
|
|
495
565
|
: TCompositeTableType;
|
|
496
566
|
|
|
497
567
|
interface OnConflictQueryBuilder<TRecord extends {}, TResult> {
|
|
498
568
|
ignore(): QueryBuilder<TRecord, TResult>;
|
|
499
569
|
merge(mergeColumns?: (keyof TRecord)[]): QueryBuilder<TRecord, TResult>;
|
|
500
|
-
merge(
|
|
570
|
+
merge(
|
|
571
|
+
data?: Extract<DbRecord<ResolveTableType<TRecord, 'update'>>, object>
|
|
572
|
+
): QueryBuilder<TRecord, TResult>;
|
|
501
573
|
}
|
|
502
574
|
|
|
503
575
|
//
|
|
504
576
|
// QueryInterface
|
|
505
577
|
//
|
|
506
|
-
type ClearStatements =
|
|
578
|
+
type ClearStatements =
|
|
579
|
+
| 'with'
|
|
580
|
+
| 'select'
|
|
581
|
+
| 'columns'
|
|
582
|
+
| 'hintComments'
|
|
583
|
+
| 'where'
|
|
584
|
+
| 'union'
|
|
585
|
+
| 'using'
|
|
586
|
+
| 'join'
|
|
587
|
+
| 'group'
|
|
588
|
+
| 'order'
|
|
589
|
+
| 'having'
|
|
590
|
+
| 'limit'
|
|
591
|
+
| 'offset'
|
|
592
|
+
| 'counter'
|
|
593
|
+
| 'counters';
|
|
507
594
|
|
|
508
595
|
interface QueryInterface<TRecord extends {} = any, TResult = any> {
|
|
509
596
|
select: Select<TRecord, TResult>;
|
|
@@ -655,8 +742,8 @@ export declare namespace Knex {
|
|
|
655
742
|
any,
|
|
656
743
|
any
|
|
657
744
|
>
|
|
658
|
-
|
|
659
|
-
|
|
745
|
+
? DeferredKeySelection<TBase, never>[]
|
|
746
|
+
: TResult
|
|
660
747
|
>;
|
|
661
748
|
clearWhere(): QueryBuilder<TRecord, TResult>;
|
|
662
749
|
clearGroup(): QueryBuilder<TRecord, TResult>;
|
|
@@ -666,12 +753,26 @@ export declare namespace Knex {
|
|
|
666
753
|
clear(statement: ClearStatements): QueryBuilder<TRecord, TResult>;
|
|
667
754
|
|
|
668
755
|
// Paging
|
|
669
|
-
offset(
|
|
670
|
-
|
|
756
|
+
offset(
|
|
757
|
+
offset: number,
|
|
758
|
+
options?: boolean | Readonly<{ skipBinding?: boolean }>
|
|
759
|
+
): QueryBuilder<TRecord, TResult>;
|
|
760
|
+
limit(
|
|
761
|
+
limit: number,
|
|
762
|
+
options?: string | Readonly<{ skipBinding?: boolean }>
|
|
763
|
+
): QueryBuilder<TRecord, TResult>;
|
|
671
764
|
|
|
672
765
|
// Aggregation
|
|
673
|
-
count: AsymmetricAggregation<
|
|
674
|
-
|
|
766
|
+
count: AsymmetricAggregation<
|
|
767
|
+
TRecord,
|
|
768
|
+
TResult,
|
|
769
|
+
Lookup<ResultTypes.Registry, 'Count', number | string>
|
|
770
|
+
>;
|
|
771
|
+
countDistinct: AsymmetricAggregation<
|
|
772
|
+
TRecord,
|
|
773
|
+
TResult,
|
|
774
|
+
Lookup<ResultTypes.Registry, 'Count', number | string>
|
|
775
|
+
>;
|
|
675
776
|
min: TypePreservingAggregation<TRecord, TResult>;
|
|
676
777
|
max: TypePreservingAggregation<TRecord, TResult>;
|
|
677
778
|
sum: TypePreservingAggregation<TRecord, TResult>;
|
|
@@ -703,7 +804,10 @@ export declare namespace Knex {
|
|
|
703
804
|
rowNumber: AnalyticFunction<TRecord, TResult>;
|
|
704
805
|
|
|
705
806
|
// Others
|
|
706
|
-
first: Select<
|
|
807
|
+
first: Select<
|
|
808
|
+
TRecord,
|
|
809
|
+
DeferredKeySelection.AddUnionMember<UnwrapArrayMember<TResult>, undefined>
|
|
810
|
+
>;
|
|
707
811
|
|
|
708
812
|
pluck<K extends keyof TRecord>(
|
|
709
813
|
column: K
|
|
@@ -712,7 +816,9 @@ export declare namespace Knex {
|
|
|
712
816
|
|
|
713
817
|
insert(
|
|
714
818
|
data: TRecord extends CompositeTableType<unknown>
|
|
715
|
-
?
|
|
819
|
+
?
|
|
820
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
821
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
716
822
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
717
823
|
returning: '*',
|
|
718
824
|
options?: DMLOptions
|
|
@@ -726,7 +832,9 @@ export declare namespace Knex {
|
|
|
726
832
|
>[]
|
|
727
833
|
>(
|
|
728
834
|
data: TRecord extends CompositeTableType<unknown>
|
|
729
|
-
?
|
|
835
|
+
?
|
|
836
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
837
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
730
838
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
731
839
|
returning: TKey,
|
|
732
840
|
options?: DMLOptions
|
|
@@ -740,7 +848,9 @@ export declare namespace Knex {
|
|
|
740
848
|
>[]
|
|
741
849
|
>(
|
|
742
850
|
data: TRecord extends CompositeTableType<unknown>
|
|
743
|
-
?
|
|
851
|
+
?
|
|
852
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
853
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
744
854
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
745
855
|
returning: readonly TKey[],
|
|
746
856
|
options?: DMLOptions
|
|
@@ -754,7 +864,9 @@ export declare namespace Knex {
|
|
|
754
864
|
>[]
|
|
755
865
|
>(
|
|
756
866
|
data: TRecord extends CompositeTableType<unknown>
|
|
757
|
-
?
|
|
867
|
+
?
|
|
868
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
869
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
758
870
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
759
871
|
returning: TKey,
|
|
760
872
|
options?: DMLOptions
|
|
@@ -768,20 +880,26 @@ export declare namespace Knex {
|
|
|
768
880
|
>[]
|
|
769
881
|
>(
|
|
770
882
|
data: TRecord extends CompositeTableType<unknown>
|
|
771
|
-
?
|
|
883
|
+
?
|
|
884
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
885
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
772
886
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
773
887
|
returning: readonly TKey[],
|
|
774
888
|
options?: DMLOptions
|
|
775
889
|
): QueryBuilder<TRecord, TResult2>;
|
|
776
890
|
insert<TResult2 = number[]>(
|
|
777
891
|
data: TRecord extends CompositeTableType<unknown>
|
|
778
|
-
?
|
|
892
|
+
?
|
|
893
|
+
| ResolveTableType<TRecord, 'insert'>
|
|
894
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
|
|
779
895
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>
|
|
780
896
|
): QueryBuilder<TRecord, TResult2>;
|
|
781
897
|
|
|
782
898
|
upsert(
|
|
783
899
|
data: TRecord extends CompositeTableType<unknown>
|
|
784
|
-
?
|
|
900
|
+
?
|
|
901
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
902
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
785
903
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
786
904
|
returning: '*',
|
|
787
905
|
options?: DMLOptions
|
|
@@ -792,10 +910,12 @@ export declare namespace Knex {
|
|
|
792
910
|
UnwrapArrayMember<TResult>,
|
|
793
911
|
ResolveTableType<TRecord>,
|
|
794
912
|
TKey
|
|
795
|
-
|
|
796
|
-
|
|
913
|
+
>[]
|
|
914
|
+
>(
|
|
797
915
|
data: TRecord extends CompositeTableType<unknown>
|
|
798
|
-
?
|
|
916
|
+
?
|
|
917
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
918
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
799
919
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
800
920
|
returning: TKey,
|
|
801
921
|
options?: DMLOptions
|
|
@@ -806,10 +926,12 @@ export declare namespace Knex {
|
|
|
806
926
|
UnwrapArrayMember<TResult>,
|
|
807
927
|
ResolveTableType<TRecord>,
|
|
808
928
|
TKey
|
|
809
|
-
|
|
810
|
-
|
|
929
|
+
>[]
|
|
930
|
+
>(
|
|
811
931
|
data: TRecord extends CompositeTableType<unknown>
|
|
812
|
-
?
|
|
932
|
+
?
|
|
933
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
934
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
813
935
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
814
936
|
returning: readonly TKey[],
|
|
815
937
|
options?: DMLOptions
|
|
@@ -820,10 +942,12 @@ export declare namespace Knex {
|
|
|
820
942
|
UnwrapArrayMember<TResult>,
|
|
821
943
|
TRecord,
|
|
822
944
|
TKey
|
|
823
|
-
|
|
824
|
-
|
|
945
|
+
>[]
|
|
946
|
+
>(
|
|
825
947
|
data: TRecord extends CompositeTableType<unknown>
|
|
826
|
-
?
|
|
948
|
+
?
|
|
949
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
950
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
827
951
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
828
952
|
returning: TKey,
|
|
829
953
|
options?: DMLOptions
|
|
@@ -834,17 +958,21 @@ export declare namespace Knex {
|
|
|
834
958
|
UnwrapArrayMember<TResult>,
|
|
835
959
|
TRecord,
|
|
836
960
|
TKey
|
|
837
|
-
|
|
838
|
-
|
|
961
|
+
>[]
|
|
962
|
+
>(
|
|
839
963
|
data: TRecord extends CompositeTableType<unknown>
|
|
840
|
-
?
|
|
964
|
+
?
|
|
965
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
966
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
841
967
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>,
|
|
842
968
|
returning: readonly TKey[],
|
|
843
969
|
options?: DMLOptions
|
|
844
970
|
): QueryBuilder<TRecord, TResult2>;
|
|
845
971
|
upsert<TResult2 = number[]>(
|
|
846
972
|
data: TRecord extends CompositeTableType<unknown>
|
|
847
|
-
?
|
|
973
|
+
?
|
|
974
|
+
| ResolveTableType<TRecord, 'upsert'>
|
|
975
|
+
| ReadonlyArray<ResolveTableType<TRecord, 'upsert'>>
|
|
848
976
|
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>
|
|
849
977
|
): QueryBuilder<TRecord, TResult2>;
|
|
850
978
|
|
|
@@ -903,7 +1031,9 @@ export declare namespace Knex {
|
|
|
903
1031
|
TKey
|
|
904
1032
|
>[]
|
|
905
1033
|
>(
|
|
906
|
-
data: TRecord extends CompositeTableType<unknown>
|
|
1034
|
+
data: TRecord extends CompositeTableType<unknown>
|
|
1035
|
+
? ResolveTableType<TRecord, 'update'>
|
|
1036
|
+
: DbRecordArr<TRecord>,
|
|
907
1037
|
returning: TKey,
|
|
908
1038
|
options?: DMLOptions
|
|
909
1039
|
): QueryBuilder<TRecord, TResult2>;
|
|
@@ -915,7 +1045,9 @@ export declare namespace Knex {
|
|
|
915
1045
|
TKey
|
|
916
1046
|
>[]
|
|
917
1047
|
>(
|
|
918
|
-
data: TRecord extends CompositeTableType<unknown>
|
|
1048
|
+
data: TRecord extends CompositeTableType<unknown>
|
|
1049
|
+
? ResolveTableType<TRecord, 'update'>
|
|
1050
|
+
: DbRecordArr<TRecord>,
|
|
919
1051
|
returning: readonly TKey[],
|
|
920
1052
|
options?: DMLOptions
|
|
921
1053
|
): QueryBuilder<TRecord, TResult2>;
|
|
@@ -927,7 +1059,9 @@ export declare namespace Knex {
|
|
|
927
1059
|
TKey
|
|
928
1060
|
>[]
|
|
929
1061
|
>(
|
|
930
|
-
data: TRecord extends CompositeTableType<unknown>
|
|
1062
|
+
data: TRecord extends CompositeTableType<unknown>
|
|
1063
|
+
? ResolveTableType<TRecord, 'update'>
|
|
1064
|
+
: DbRecordArr<TRecord>,
|
|
931
1065
|
returning: TKey | readonly TKey[],
|
|
932
1066
|
options?: DMLOptions
|
|
933
1067
|
): QueryBuilder<TRecord, TResult2>;
|
|
@@ -939,17 +1073,27 @@ export declare namespace Knex {
|
|
|
939
1073
|
TKey
|
|
940
1074
|
>[]
|
|
941
1075
|
>(
|
|
942
|
-
data: TRecord extends CompositeTableType<unknown>
|
|
1076
|
+
data: TRecord extends CompositeTableType<unknown>
|
|
1077
|
+
? ResolveTableType<TRecord, 'update'>
|
|
1078
|
+
: DbRecordArr<TRecord>,
|
|
943
1079
|
returning: readonly TKey[],
|
|
944
1080
|
options?: DMLOptions
|
|
945
1081
|
): QueryBuilder<TRecord, TResult2>;
|
|
946
1082
|
update<TResult2 = number>(
|
|
947
|
-
data: TRecord extends CompositeTableType<unknown>
|
|
1083
|
+
data: TRecord extends CompositeTableType<unknown>
|
|
1084
|
+
? ResolveTableType<TRecord, 'update'>
|
|
1085
|
+
: DbRecordArr<TRecord>
|
|
948
1086
|
): QueryBuilder<TRecord, TResult2>;
|
|
949
1087
|
|
|
950
|
-
update<TResult2 = number>(
|
|
1088
|
+
update<TResult2 = number>(
|
|
1089
|
+
columnName: string,
|
|
1090
|
+
value: Value
|
|
1091
|
+
): QueryBuilder<TRecord, TResult2>;
|
|
951
1092
|
|
|
952
|
-
returning(
|
|
1093
|
+
returning(
|
|
1094
|
+
column: '*',
|
|
1095
|
+
options?: DMLOptions
|
|
1096
|
+
): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
|
953
1097
|
returning<
|
|
954
1098
|
TKey extends StrKey<ResolveTableType<TRecord>>,
|
|
955
1099
|
TResult2 = DeferredKeySelection.Augment<
|
|
@@ -964,7 +1108,11 @@ export declare namespace Knex {
|
|
|
964
1108
|
returning<
|
|
965
1109
|
TKey extends StrKey<ResolveTableType<TRecord>>,
|
|
966
1110
|
TResult2 = DeferredKeySelection.SetSingle<
|
|
967
|
-
DeferredKeySelection.Augment<
|
|
1111
|
+
DeferredKeySelection.Augment<
|
|
1112
|
+
UnwrapArrayMember<TResult>,
|
|
1113
|
+
ResolveTableType<TRecord>,
|
|
1114
|
+
TKey
|
|
1115
|
+
>,
|
|
968
1116
|
false
|
|
969
1117
|
>[]
|
|
970
1118
|
>(
|
|
@@ -976,28 +1124,18 @@ export declare namespace Knex {
|
|
|
976
1124
|
options?: DMLOptions
|
|
977
1125
|
): QueryBuilder<TRecord, TResult2>;
|
|
978
1126
|
|
|
979
|
-
onConflict<
|
|
980
|
-
TKey extends StrKey<ResolveTableType<TRecord>>
|
|
981
|
-
>(
|
|
1127
|
+
onConflict<TKey extends StrKey<ResolveTableType<TRecord>>>(
|
|
982
1128
|
column: TKey
|
|
983
1129
|
): OnConflictQueryBuilder<TRecord, TResult>;
|
|
984
|
-
onConflict<
|
|
985
|
-
TKey extends StrKey<ResolveTableType<TRecord>>
|
|
986
|
-
>(
|
|
1130
|
+
onConflict<TKey extends StrKey<ResolveTableType<TRecord>>>(
|
|
987
1131
|
columns: readonly TKey[]
|
|
988
1132
|
): OnConflictQueryBuilder<TRecord, TResult>;
|
|
989
1133
|
|
|
990
|
-
onConflict(
|
|
991
|
-
columns: string
|
|
992
|
-
): OnConflictQueryBuilder<TRecord, TResult>;
|
|
1134
|
+
onConflict(columns: string): OnConflictQueryBuilder<TRecord, TResult>;
|
|
993
1135
|
|
|
994
|
-
onConflict(
|
|
995
|
-
columns: string[]
|
|
996
|
-
): OnConflictQueryBuilder<TRecord, TResult>;
|
|
1136
|
+
onConflict(columns: string[]): OnConflictQueryBuilder<TRecord, TResult>;
|
|
997
1137
|
|
|
998
|
-
onConflict(
|
|
999
|
-
raw: Raw
|
|
1000
|
-
): OnConflictQueryBuilder<TRecord, TResult>;
|
|
1138
|
+
onConflict(raw: Raw): OnConflictQueryBuilder<TRecord, TResult>;
|
|
1001
1139
|
|
|
1002
1140
|
onConflict(): OnConflictQueryBuilder<TRecord, TResult>;
|
|
1003
1141
|
|
|
@@ -1073,79 +1211,98 @@ export declare namespace Knex {
|
|
|
1073
1211
|
(columnName: string): QueryBuilder<TRecord, TResult>;
|
|
1074
1212
|
}
|
|
1075
1213
|
|
|
1076
|
-
type IntersectAliases<AliasUT> =
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
AliasUT extends (infer I)[]
|
|
1214
|
+
type IntersectAliases<AliasUT> = UnionToIntersection<
|
|
1215
|
+
IncompatibleToAlt<
|
|
1216
|
+
AliasUT extends (infer I)[]
|
|
1080
1217
|
? I extends Ref<any, infer TMapping>
|
|
1081
|
-
|
|
1082
|
-
|
|
1218
|
+
? TMapping
|
|
1219
|
+
: I
|
|
1083
1220
|
: never,
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1221
|
+
Dict,
|
|
1222
|
+
{}
|
|
1223
|
+
>
|
|
1224
|
+
> & {}; // filters out `null` and `undefined`
|
|
1088
1225
|
|
|
1089
1226
|
interface AliasQueryBuilder<TRecord extends {} = any, TResult = unknown[]> {
|
|
1090
1227
|
<
|
|
1091
1228
|
AliasUT extends InferrableColumnDescriptor<ResolveTableType<TRecord>>[],
|
|
1092
|
-
TResult2 = ArrayIfAlready<
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1229
|
+
TResult2 = ArrayIfAlready<
|
|
1230
|
+
TResult,
|
|
1231
|
+
DeferredKeySelection.Augment<
|
|
1232
|
+
UnwrapArrayMember<TResult>,
|
|
1233
|
+
ResolveTableType<TRecord>,
|
|
1234
|
+
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
|
1235
|
+
IntersectAliases<AliasUT>
|
|
1236
|
+
>
|
|
1237
|
+
>
|
|
1238
|
+
>(
|
|
1099
1239
|
...aliases: AliasUT
|
|
1100
1240
|
): QueryBuilder<TRecord, TResult2>;
|
|
1101
1241
|
|
|
1102
1242
|
<
|
|
1103
1243
|
AliasUT extends InferrableColumnDescriptor<ResolveTableType<TRecord>>[],
|
|
1104
|
-
TResult2 = ArrayIfAlready<
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
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
|
+
>(
|
|
1111
1254
|
aliases: AliasUT
|
|
1112
1255
|
): QueryBuilder<TRecord, TResult2>;
|
|
1113
1256
|
|
|
1114
1257
|
<
|
|
1115
1258
|
AliasUT extends (Dict | string)[],
|
|
1116
|
-
TResult2 = ArrayIfAlready<
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
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
|
+
>(
|
|
1123
1269
|
...aliases: AliasUT
|
|
1124
1270
|
): QueryBuilder<TRecord, TResult2>;
|
|
1125
1271
|
|
|
1126
1272
|
<
|
|
1127
1273
|
AliasUT extends (Dict | string)[],
|
|
1128
|
-
TResult2 = ArrayIfAlready<
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1274
|
+
TResult2 = ArrayIfAlready<
|
|
1275
|
+
TResult,
|
|
1276
|
+
DeferredKeySelection.Augment<
|
|
1277
|
+
UnwrapArrayMember<TResult>,
|
|
1278
|
+
TRecord,
|
|
1279
|
+
IncompatibleToAlt<ArrayMember<AliasUT>, string, never>,
|
|
1280
|
+
IntersectAliases<AliasUT>
|
|
1281
|
+
>
|
|
1282
|
+
>
|
|
1283
|
+
>(
|
|
1135
1284
|
aliases: AliasUT
|
|
1136
1285
|
): QueryBuilder<TRecord, TResult2>;
|
|
1137
1286
|
}
|
|
1138
1287
|
|
|
1139
1288
|
interface Select<TRecord extends {} = any, TResult = unknown[]>
|
|
1140
1289
|
extends AliasQueryBuilder<TRecord, TResult>,
|
|
1141
|
-
|
|
1290
|
+
ColumnNameQueryBuilder<TRecord, TResult> {
|
|
1142
1291
|
(): QueryBuilder<TRecord, TResult>;
|
|
1143
1292
|
|
|
1144
|
-
<
|
|
1293
|
+
<
|
|
1294
|
+
TResult2 = ArrayIfAlready<TResult, any>,
|
|
1295
|
+
TInnerRecord extends {} = any,
|
|
1296
|
+
TInnerResult = any
|
|
1297
|
+
>(
|
|
1145
1298
|
...subQueryBuilders: readonly QueryBuilder<TInnerRecord, TInnerResult>[]
|
|
1146
1299
|
): QueryBuilder<TRecord, TResult2>;
|
|
1147
1300
|
|
|
1148
|
-
<
|
|
1301
|
+
<
|
|
1302
|
+
TResult2 = ArrayIfAlready<TResult, any>,
|
|
1303
|
+
TInnerRecord extends {} = any,
|
|
1304
|
+
TInnerResult = any
|
|
1305
|
+
>(
|
|
1149
1306
|
subQueryBuilders: readonly QueryBuilder<TInnerRecord, TInnerResult>[]
|
|
1150
1307
|
): QueryBuilder<TRecord, TResult2>;
|
|
1151
1308
|
}
|
|
@@ -1158,20 +1315,42 @@ export declare namespace Knex {
|
|
|
1158
1315
|
}
|
|
1159
1316
|
|
|
1160
1317
|
interface JsonExtract<TRecord extends {} = any, TResult = any> {
|
|
1161
|
-
(
|
|
1162
|
-
|
|
1318
|
+
(
|
|
1319
|
+
column: string | Raw | QueryBuilder,
|
|
1320
|
+
path: string,
|
|
1321
|
+
alias?: string,
|
|
1322
|
+
singleValue?: boolean
|
|
1323
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1324
|
+
(column: JsonExtraction[] | any[][], singleValue?: boolean): QueryBuilder<
|
|
1325
|
+
TRecord,
|
|
1326
|
+
TResult
|
|
1327
|
+
>;
|
|
1163
1328
|
}
|
|
1164
1329
|
|
|
1165
1330
|
interface JsonSet<TRecord extends {} = any, TResult = any> {
|
|
1166
|
-
(
|
|
1331
|
+
(
|
|
1332
|
+
column: string | Raw | QueryBuilder,
|
|
1333
|
+
path: string,
|
|
1334
|
+
value: any,
|
|
1335
|
+
alias?: string
|
|
1336
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1167
1337
|
}
|
|
1168
1338
|
|
|
1169
1339
|
interface JsonInsert<TRecord extends {} = any, TResult = any> {
|
|
1170
|
-
(
|
|
1340
|
+
(
|
|
1341
|
+
column: string | Raw | QueryBuilder,
|
|
1342
|
+
path: string,
|
|
1343
|
+
value: any,
|
|
1344
|
+
alias?: string
|
|
1345
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1171
1346
|
}
|
|
1172
1347
|
|
|
1173
1348
|
interface JsonRemove<TRecord extends {} = any, TResult = any> {
|
|
1174
|
-
(
|
|
1349
|
+
(
|
|
1350
|
+
column: string | Raw | QueryBuilder,
|
|
1351
|
+
path: string,
|
|
1352
|
+
alias?: string
|
|
1353
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1175
1354
|
}
|
|
1176
1355
|
|
|
1177
1356
|
interface HintComment<TRecord extends {} = any, TResult = any> {
|
|
@@ -1183,29 +1362,32 @@ export declare namespace Knex {
|
|
|
1183
1362
|
<
|
|
1184
1363
|
TTable extends TableNames,
|
|
1185
1364
|
TRecord2 extends {} = TableType<TTable>,
|
|
1186
|
-
TResult2 = DeferredKeySelection.ReplaceBase<
|
|
1187
|
-
|
|
1365
|
+
TResult2 = DeferredKeySelection.ReplaceBase<
|
|
1366
|
+
TResult,
|
|
1367
|
+
ResolveTableType<TRecord2>
|
|
1368
|
+
>
|
|
1369
|
+
>(
|
|
1188
1370
|
tableName: TTable,
|
|
1189
1371
|
options?: TableOptions
|
|
1190
1372
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1191
1373
|
<
|
|
1192
1374
|
TRecord2 extends {} = {},
|
|
1193
1375
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1194
|
-
|
|
1376
|
+
>(
|
|
1195
1377
|
tableName: TableDescriptor | AliasDict,
|
|
1196
1378
|
options?: TableOptions
|
|
1197
1379
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1198
1380
|
<
|
|
1199
1381
|
TRecord2 extends {} = {},
|
|
1200
1382
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1201
|
-
|
|
1383
|
+
>(
|
|
1202
1384
|
callback: Function,
|
|
1203
1385
|
options?: TableOptions
|
|
1204
1386
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1205
1387
|
<
|
|
1206
1388
|
TRecord2 extends {} = {},
|
|
1207
1389
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1208
|
-
|
|
1390
|
+
>(
|
|
1209
1391
|
raw: Raw,
|
|
1210
1392
|
options?: TableOptions
|
|
1211
1393
|
): QueryBuilder<TRecord2, TResult2>;
|
|
@@ -1236,15 +1418,15 @@ export declare namespace Knex {
|
|
|
1236
1418
|
TJoinTargetRecord extends {} = any,
|
|
1237
1419
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1238
1420
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1239
|
-
|
|
1421
|
+
>(
|
|
1240
1422
|
raw: Raw
|
|
1241
1423
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1242
1424
|
<
|
|
1243
1425
|
TTable extends TableNames,
|
|
1244
1426
|
TRecord2 extends {} = ResolveTableType<TRecord> &
|
|
1245
|
-
|
|
1427
|
+
ResolveTableType<TableType<TTable>>,
|
|
1246
1428
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1247
|
-
|
|
1429
|
+
>(
|
|
1248
1430
|
tableName: TTable,
|
|
1249
1431
|
clause: JoinCallback
|
|
1250
1432
|
): QueryBuilder<TRecord2, TResult2>;
|
|
@@ -1252,7 +1434,7 @@ export declare namespace Knex {
|
|
|
1252
1434
|
TJoinTargetRecord extends {} = any,
|
|
1253
1435
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1254
1436
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1255
|
-
|
|
1437
|
+
>(
|
|
1256
1438
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1257
1439
|
clause: JoinCallback
|
|
1258
1440
|
): QueryBuilder<TRecord2, TResult2>;
|
|
@@ -1260,7 +1442,7 @@ export declare namespace Knex {
|
|
|
1260
1442
|
TJoinTargetRecord extends {} = any,
|
|
1261
1443
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1262
1444
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1263
|
-
|
|
1445
|
+
>(
|
|
1264
1446
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1265
1447
|
columns: { [key: string]: string | number | boolean | Raw }
|
|
1266
1448
|
): QueryBuilder<TRecord2, TResult2>;
|
|
@@ -1268,19 +1450,20 @@ export declare namespace Knex {
|
|
|
1268
1450
|
TJoinTargetRecord extends {} = any,
|
|
1269
1451
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1270
1452
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1271
|
-
|
|
1453
|
+
>(
|
|
1272
1454
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1273
1455
|
raw: Raw
|
|
1274
1456
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1275
1457
|
<
|
|
1276
1458
|
TTable1 extends TableNames,
|
|
1277
1459
|
TTable2 extends TableNames,
|
|
1278
|
-
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1460
|
+
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1461
|
+
StrKey<TRecord1>,
|
|
1279
1462
|
TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
|
1280
1463
|
TRecord1 = ResolveTableType<TRecord>,
|
|
1281
1464
|
TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
|
1282
1465
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1283
|
-
|
|
1466
|
+
>(
|
|
1284
1467
|
tableName: TTable2,
|
|
1285
1468
|
column1: `${TTable1}.${TKey1}`,
|
|
1286
1469
|
column2: `${TTable2}.${TKey2}`
|
|
@@ -1288,12 +1471,13 @@ export declare namespace Knex {
|
|
|
1288
1471
|
<
|
|
1289
1472
|
TTable1 extends TableNames,
|
|
1290
1473
|
TTable2 extends TableNames,
|
|
1291
|
-
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1474
|
+
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1475
|
+
StrKey<TRecord1>,
|
|
1292
1476
|
TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
|
1293
1477
|
TRecord1 = ResolveTableType<TRecord>,
|
|
1294
1478
|
TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
|
1295
1479
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1296
|
-
|
|
1480
|
+
>(
|
|
1297
1481
|
tableName: TTable2,
|
|
1298
1482
|
column1: `${TTable2}.${TKey2}`,
|
|
1299
1483
|
column2: `${TTable1}.${TKey1}`
|
|
@@ -1302,7 +1486,7 @@ export declare namespace Knex {
|
|
|
1302
1486
|
TJoinTargetRecord extends {} = any,
|
|
1303
1487
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1304
1488
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1305
|
-
|
|
1489
|
+
>(
|
|
1306
1490
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1307
1491
|
column1: string,
|
|
1308
1492
|
column2: string
|
|
@@ -1311,7 +1495,7 @@ export declare namespace Knex {
|
|
|
1311
1495
|
TJoinTargetRecord extends {} = any,
|
|
1312
1496
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1313
1497
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1314
|
-
|
|
1498
|
+
>(
|
|
1315
1499
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1316
1500
|
column1: string,
|
|
1317
1501
|
raw: Raw
|
|
@@ -1319,12 +1503,13 @@ export declare namespace Knex {
|
|
|
1319
1503
|
<
|
|
1320
1504
|
TTable1 extends TableNames,
|
|
1321
1505
|
TTable2 extends TableNames,
|
|
1322
|
-
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1506
|
+
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1507
|
+
StrKey<TRecord1>,
|
|
1323
1508
|
TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
|
1324
1509
|
TRecord1 = ResolveTableType<TRecord>,
|
|
1325
1510
|
TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
|
1326
1511
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1327
|
-
|
|
1512
|
+
>(
|
|
1328
1513
|
tableName: TTable2,
|
|
1329
1514
|
column1: `${TTable1}.${TKey1}`,
|
|
1330
1515
|
operator: string,
|
|
@@ -1333,22 +1518,23 @@ export declare namespace Knex {
|
|
|
1333
1518
|
<
|
|
1334
1519
|
TTable1 extends TableNames,
|
|
1335
1520
|
TTable2 extends TableNames,
|
|
1336
|
-
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1521
|
+
TKey1 extends StrKey<ResolveTableType<TableType<TTable1>>> &
|
|
1522
|
+
StrKey<TRecord1>,
|
|
1337
1523
|
TKey2 extends StrKey<ResolveTableType<TableType<TTable2>>>,
|
|
1338
1524
|
TRecord1 = ResolveTableType<TRecord>,
|
|
1339
1525
|
TRecord2 extends {} = TRecord1 & ResolveTableType<TableType<TTable2>>,
|
|
1340
1526
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1341
|
-
|
|
1527
|
+
>(
|
|
1342
1528
|
tableName: TTable2,
|
|
1343
1529
|
column1: `${TTable2}.${TKey2}`,
|
|
1344
1530
|
operator: string,
|
|
1345
|
-
column2: `${TTable1}.${TKey1}
|
|
1531
|
+
column2: `${TTable1}.${TKey1}`
|
|
1346
1532
|
): QueryBuilder<TRecord2, TResult2>;
|
|
1347
1533
|
<
|
|
1348
1534
|
TJoinTargetRecord extends {} = any,
|
|
1349
1535
|
TRecord2 extends {} = TRecord & TJoinTargetRecord,
|
|
1350
1536
|
TResult2 = DeferredKeySelection.ReplaceBase<TResult, TRecord2>
|
|
1351
|
-
|
|
1537
|
+
>(
|
|
1352
1538
|
tableName: TableDescriptor | AliasDict | QueryCallback,
|
|
1353
1539
|
column1: string,
|
|
1354
1540
|
operator: string,
|
|
@@ -1405,8 +1591,18 @@ export declare namespace Knex {
|
|
|
1405
1591
|
onNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
|
1406
1592
|
andOnNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
|
1407
1593
|
orOnNotBetween(column1: string, range: readonly [any, any]): JoinClause;
|
|
1408
|
-
onJsonPathEquals(
|
|
1409
|
-
|
|
1594
|
+
onJsonPathEquals(
|
|
1595
|
+
columnFirst: string,
|
|
1596
|
+
jsonPathFirst: string,
|
|
1597
|
+
columnSecond: string,
|
|
1598
|
+
jsonPathSecond: string
|
|
1599
|
+
): JoinClause;
|
|
1600
|
+
orOnJsonPathEquals(
|
|
1601
|
+
columnFirst: string,
|
|
1602
|
+
jsonPathFirst: string,
|
|
1603
|
+
columnSecond: string,
|
|
1604
|
+
jsonPathSecond: string
|
|
1605
|
+
): JoinClause;
|
|
1410
1606
|
using(
|
|
1411
1607
|
column: string | readonly string[] | Raw | { [key: string]: string | Raw }
|
|
1412
1608
|
): JoinClause;
|
|
@@ -1426,19 +1622,26 @@ export declare namespace Knex {
|
|
|
1426
1622
|
|
|
1427
1623
|
interface With<TRecord extends {} = any, TResult = unknown[]>
|
|
1428
1624
|
extends WithRaw<TRecord, TResult>,
|
|
1429
|
-
|
|
1625
|
+
WithWrapped<TRecord, TResult> {}
|
|
1430
1626
|
|
|
1431
1627
|
interface WithRaw<TRecord extends {} = any, TResult = unknown[]> {
|
|
1432
1628
|
(alias: string, raw: Raw | QueryBuilder): QueryBuilder<TRecord, TResult>;
|
|
1433
|
-
(
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
(
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1629
|
+
(
|
|
1630
|
+
alias: string,
|
|
1631
|
+
sql: string,
|
|
1632
|
+
bindings?: readonly Value[] | Object
|
|
1633
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1634
|
+
(
|
|
1635
|
+
alias: string,
|
|
1636
|
+
columnList: string[],
|
|
1637
|
+
raw: Raw | QueryBuilder
|
|
1638
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1639
|
+
(
|
|
1640
|
+
alias: string,
|
|
1641
|
+
columnList: string[],
|
|
1642
|
+
sql: string,
|
|
1643
|
+
bindings?: readonly Value[] | Object
|
|
1644
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1442
1645
|
}
|
|
1443
1646
|
|
|
1444
1647
|
interface WithSchema<TRecord extends {} = any, TResult = unknown[]> {
|
|
@@ -1451,7 +1654,11 @@ export declare namespace Knex {
|
|
|
1451
1654
|
alias: string,
|
|
1452
1655
|
callback: (queryBuilder: QueryBuilder) => any
|
|
1453
1656
|
): QueryBuilder<TRecord, TResult>;
|
|
1454
|
-
(
|
|
1657
|
+
(
|
|
1658
|
+
alias: string,
|
|
1659
|
+
columnList: string[],
|
|
1660
|
+
queryBuilder: QueryBuilder
|
|
1661
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1455
1662
|
(
|
|
1456
1663
|
alias: string,
|
|
1457
1664
|
columnList: string[],
|
|
@@ -1461,13 +1668,16 @@ export declare namespace Knex {
|
|
|
1461
1668
|
|
|
1462
1669
|
interface Where<TRecord extends {} = any, TResult = unknown>
|
|
1463
1670
|
extends WhereRaw<TRecord, TResult>,
|
|
1464
|
-
|
|
1465
|
-
|
|
1671
|
+
WhereWrapped<TRecord, TResult>,
|
|
1672
|
+
WhereNull<TRecord, TResult> {
|
|
1466
1673
|
(raw: Raw): QueryBuilder<TRecord, TResult>;
|
|
1467
1674
|
|
|
1468
1675
|
(callback: QueryCallback<TRecord, TResult>): QueryBuilder<TRecord, TResult>;
|
|
1469
1676
|
|
|
1470
|
-
(object: DbRecord<ResolveTableType<TRecord>>): QueryBuilder<
|
|
1677
|
+
(object: DbRecord<ResolveTableType<TRecord>>): QueryBuilder<
|
|
1678
|
+
TRecord,
|
|
1679
|
+
TResult
|
|
1680
|
+
>;
|
|
1471
1681
|
|
|
1472
1682
|
(object: Readonly<Object>): QueryBuilder<TRecord, TResult>;
|
|
1473
1683
|
|
|
@@ -1489,7 +1699,11 @@ export declare namespace Knex {
|
|
|
1489
1699
|
TResult
|
|
1490
1700
|
>;
|
|
1491
1701
|
|
|
1492
|
-
<
|
|
1702
|
+
<
|
|
1703
|
+
T extends keyof ResolveTableType<TRecord>,
|
|
1704
|
+
TRecordInner extends {},
|
|
1705
|
+
TResultInner
|
|
1706
|
+
>(
|
|
1493
1707
|
columnName: T,
|
|
1494
1708
|
operator: ComparisonOperator,
|
|
1495
1709
|
value: QueryBuilder<TRecordInner, TResultInner>
|
|
@@ -1532,7 +1746,10 @@ export declare namespace Knex {
|
|
|
1532
1746
|
columnName: K,
|
|
1533
1747
|
range: readonly [DbColumn<TRecord[K]>, DbColumn<TRecord[K]>]
|
|
1534
1748
|
): QueryBuilder<TRecord, TResult>;
|
|
1535
|
-
(columnName: string, range: readonly [Value, Value]): QueryBuilder<
|
|
1749
|
+
(columnName: string, range: readonly [Value, Value]): QueryBuilder<
|
|
1750
|
+
TRecord,
|
|
1751
|
+
TResult
|
|
1752
|
+
>;
|
|
1536
1753
|
}
|
|
1537
1754
|
|
|
1538
1755
|
interface WhereExists<TRecord extends {} = any, TResult = unknown[]> {
|
|
@@ -1547,7 +1764,12 @@ export declare namespace Knex {
|
|
|
1547
1764
|
}
|
|
1548
1765
|
|
|
1549
1766
|
interface WhereJsonPath<TRecord extends {} = any, TResult = unknown[]> {
|
|
1550
|
-
(
|
|
1767
|
+
(
|
|
1768
|
+
columnName: keyof TRecord,
|
|
1769
|
+
jsonPath: string,
|
|
1770
|
+
operator: string,
|
|
1771
|
+
value: any
|
|
1772
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1551
1773
|
}
|
|
1552
1774
|
|
|
1553
1775
|
interface WhereIn<TRecord extends {} = any, TResult = unknown[]> {
|
|
@@ -1555,18 +1777,20 @@ export declare namespace Knex {
|
|
|
1555
1777
|
columnName: K,
|
|
1556
1778
|
values: readonly DbColumn<ResolveTableType<TRecord>[K]>[] | QueryCallback
|
|
1557
1779
|
): QueryBuilder<TRecord, TResult>;
|
|
1558
|
-
(
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
>;
|
|
1780
|
+
(
|
|
1781
|
+
columnName: string,
|
|
1782
|
+
values: readonly Value[] | QueryCallback
|
|
1783
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1562
1784
|
<K extends keyof ResolveTableType<TRecord>>(
|
|
1563
1785
|
columnNames: readonly K[],
|
|
1564
|
-
values:
|
|
1786
|
+
values:
|
|
1787
|
+
| readonly (readonly DbColumn<ResolveTableType<TRecord>[K]>[])[]
|
|
1788
|
+
| QueryCallback
|
|
1789
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1790
|
+
(
|
|
1791
|
+
columnNames: readonly string[],
|
|
1792
|
+
values: readonly Value[][] | QueryCallback
|
|
1565
1793
|
): QueryBuilder<TRecord, TResult>;
|
|
1566
|
-
(columnNames: readonly string[], values: readonly Value[][] | QueryCallback): QueryBuilder<
|
|
1567
|
-
TRecord,
|
|
1568
|
-
TResult
|
|
1569
|
-
>;
|
|
1570
1794
|
<K extends keyof TRecord, TRecordInner extends {}, TResultInner>(
|
|
1571
1795
|
columnName: K,
|
|
1572
1796
|
values: QueryBuilder<TRecordInner, TRecord[K]>
|
|
@@ -1589,11 +1813,18 @@ export declare namespace Knex {
|
|
|
1589
1813
|
// by extracting out a common base interface will not work because order of overloads
|
|
1590
1814
|
// is significant.
|
|
1591
1815
|
|
|
1592
|
-
interface AsymmetricAggregation<
|
|
1816
|
+
interface AsymmetricAggregation<
|
|
1817
|
+
TRecord extends {} = any,
|
|
1818
|
+
TResult = unknown[],
|
|
1819
|
+
TValue = any
|
|
1820
|
+
> {
|
|
1593
1821
|
<
|
|
1594
|
-
TOptions extends {
|
|
1595
|
-
TResult2 = AggregationQueryResult<
|
|
1596
|
-
|
|
1822
|
+
TOptions extends { as: string },
|
|
1823
|
+
TResult2 = AggregationQueryResult<
|
|
1824
|
+
TResult,
|
|
1825
|
+
{ [k in TOptions['as']]: TValue }
|
|
1826
|
+
>
|
|
1827
|
+
>(
|
|
1597
1828
|
columnName: Readonly<keyof ResolveTableType<TRecord>>,
|
|
1598
1829
|
options: Readonly<TOptions>
|
|
1599
1830
|
): QueryBuilder<TRecord, TResult2>;
|
|
@@ -1602,88 +1833,133 @@ export declare namespace Knex {
|
|
|
1602
1833
|
): QueryBuilder<TRecord, TResult2>;
|
|
1603
1834
|
<
|
|
1604
1835
|
TAliases extends {} = Record<string, string | string[] | Knex.Raw>,
|
|
1605
|
-
TResult2 = AggregationQueryResult<
|
|
1606
|
-
|
|
1836
|
+
TResult2 = AggregationQueryResult<
|
|
1837
|
+
TResult,
|
|
1838
|
+
{ [k in keyof TAliases]?: TValue }
|
|
1839
|
+
>
|
|
1840
|
+
>(
|
|
1841
|
+
aliases: TAliases
|
|
1842
|
+
): QueryBuilder<TRecord, TResult2>;
|
|
1607
1843
|
<TResult2 = AggregationQueryResult<TResult, Dict<TValue>>>(
|
|
1608
|
-
...columnNames: ReadonlyArray<
|
|
1844
|
+
...columnNames: ReadonlyArray<
|
|
1845
|
+
| Readonly<Record<string, string | string[] | Knex.Raw>>
|
|
1846
|
+
| Knex.Raw
|
|
1847
|
+
| string
|
|
1848
|
+
>
|
|
1609
1849
|
): QueryBuilder<TRecord, TResult2>;
|
|
1610
1850
|
}
|
|
1611
1851
|
|
|
1612
|
-
interface TypePreservingAggregation<
|
|
1852
|
+
interface TypePreservingAggregation<
|
|
1853
|
+
TRecord extends {} = any,
|
|
1854
|
+
TResult = unknown[],
|
|
1855
|
+
TValue = any
|
|
1856
|
+
> {
|
|
1613
1857
|
<
|
|
1614
1858
|
TKey extends keyof ResolveTableType<TRecord>,
|
|
1615
|
-
TOptions extends {
|
|
1616
|
-
TResult2 = AggregationQueryResult<
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1859
|
+
TOptions extends { as: string },
|
|
1860
|
+
TResult2 = AggregationQueryResult<
|
|
1861
|
+
TResult,
|
|
1862
|
+
{
|
|
1863
|
+
[k in TOptions['as']]: ResolveTableType<TRecord>[TKey];
|
|
1864
|
+
}
|
|
1865
|
+
>
|
|
1866
|
+
>(
|
|
1620
1867
|
columnName: Readonly<TKey>,
|
|
1621
1868
|
options: Readonly<TOptions>
|
|
1622
1869
|
): QueryBuilder<TRecord, TResult2>;
|
|
1623
1870
|
<
|
|
1624
1871
|
TKey extends keyof ResolveTableType<TRecord>,
|
|
1625
|
-
TResult2 = AggregationQueryResult<
|
|
1626
|
-
|
|
1872
|
+
TResult2 = AggregationQueryResult<
|
|
1873
|
+
TResult,
|
|
1874
|
+
Dict<ResolveTableType<TRecord>[TKey]>
|
|
1875
|
+
>
|
|
1876
|
+
>(
|
|
1627
1877
|
...columnNames: readonly TKey[]
|
|
1628
1878
|
): QueryBuilder<TRecord, TResult2>;
|
|
1629
1879
|
<
|
|
1630
|
-
TAliases extends {} = Readonly<
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1880
|
+
TAliases extends {} = Readonly<
|
|
1881
|
+
Record<string, string | string[] | Knex.Raw>
|
|
1882
|
+
>,
|
|
1883
|
+
TResult2 = AggregationQueryResult<
|
|
1884
|
+
TResult,
|
|
1885
|
+
{
|
|
1886
|
+
// We have optional here because in most dialects aggregating by multiple keys simultaneously
|
|
1887
|
+
// causes rest of the keys to be dropped and only first to be considered
|
|
1888
|
+
[K in keyof TAliases]?: K extends keyof TRecord ? TRecord[K] : TValue;
|
|
1889
|
+
}
|
|
1890
|
+
>
|
|
1891
|
+
>(
|
|
1892
|
+
aliases: TAliases
|
|
1893
|
+
): QueryBuilder<TRecord, TResult2>;
|
|
1639
1894
|
<TResult2 = AggregationQueryResult<TResult, Dict<TValue>>>(
|
|
1640
|
-
...columnNames: ReadonlyArray<
|
|
1895
|
+
...columnNames: ReadonlyArray<
|
|
1896
|
+
| Readonly<Record<string, string | readonly string[] | Knex.Raw>>
|
|
1897
|
+
| Knex.Raw
|
|
1898
|
+
| string
|
|
1899
|
+
>
|
|
1641
1900
|
): QueryBuilder<TRecord, TResult2>;
|
|
1642
1901
|
}
|
|
1643
1902
|
|
|
1644
1903
|
interface AnalyticFunction<TRecord extends {} = any, TResult = unknown[]> {
|
|
1645
1904
|
<
|
|
1646
1905
|
TAlias extends string,
|
|
1647
|
-
TResult2 = AggregationQueryResult<TResult, {[x in TAlias]: number}>
|
|
1648
|
-
|
|
1906
|
+
TResult2 = AggregationQueryResult<TResult, { [x in TAlias]: number }>
|
|
1907
|
+
>(
|
|
1908
|
+
alias: TAlias,
|
|
1909
|
+
raw: Raw | QueryCallback<TRecord, TResult>
|
|
1910
|
+
): QueryBuilder<TRecord, TResult2>;
|
|
1649
1911
|
<
|
|
1650
1912
|
TAlias extends string,
|
|
1651
1913
|
TKey extends keyof ResolveTableType<TRecord>,
|
|
1652
|
-
TResult2 = AggregationQueryResult<TResult, {[x in TAlias]: number}>
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1914
|
+
TResult2 = AggregationQueryResult<TResult, { [x in TAlias]: number }>
|
|
1915
|
+
>(
|
|
1916
|
+
alias: TAlias,
|
|
1917
|
+
orderBy:
|
|
1918
|
+
| TKey
|
|
1919
|
+
| TKey[]
|
|
1920
|
+
| {
|
|
1921
|
+
columnName: TKey;
|
|
1922
|
+
order?: 'asc' | 'desc';
|
|
1923
|
+
nulls?: 'first' | 'last';
|
|
1924
|
+
},
|
|
1925
|
+
partitionBy?: TKey | TKey[] | { columnName: TKey; order?: 'asc' | 'desc' }
|
|
1926
|
+
): QueryBuilder<TRecord, TResult2>;
|
|
1660
1927
|
}
|
|
1661
1928
|
|
|
1662
1929
|
interface GroupBy<TRecord extends {} = any, TResult = unknown[]>
|
|
1663
1930
|
extends RawQueryBuilder<TRecord, TResult>,
|
|
1664
|
-
|
|
1931
|
+
ColumnNameQueryBuilder<TRecord, TResult> {}
|
|
1665
1932
|
|
|
1666
1933
|
interface OrderBy<TRecord extends {} = any, TResult = unknown[]> {
|
|
1667
|
-
(
|
|
1668
|
-
TRecord,
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1934
|
+
(
|
|
1935
|
+
columnName: keyof TRecord | QueryBuilder,
|
|
1936
|
+
order?: 'asc' | 'desc',
|
|
1937
|
+
nulls?: 'first' | 'last'
|
|
1938
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1939
|
+
(
|
|
1940
|
+
columnName: string | QueryBuilder,
|
|
1941
|
+
order?: string,
|
|
1942
|
+
nulls?: string
|
|
1943
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1672
1944
|
(
|
|
1673
1945
|
columnDefs: Array<
|
|
1674
|
-
keyof TRecord
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1946
|
+
| keyof TRecord
|
|
1947
|
+
| Readonly<{
|
|
1948
|
+
column: keyof TRecord | QueryBuilder;
|
|
1949
|
+
order?: 'asc' | 'desc';
|
|
1950
|
+
nulls?: 'first' | 'last';
|
|
1951
|
+
}>
|
|
1679
1952
|
>
|
|
1680
1953
|
): QueryBuilder<TRecord, TResult>;
|
|
1681
1954
|
(
|
|
1682
|
-
columnDefs: Array<
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1955
|
+
columnDefs: Array<
|
|
1956
|
+
| string
|
|
1957
|
+
| Readonly<{
|
|
1958
|
+
column: string | QueryBuilder;
|
|
1959
|
+
order?: string;
|
|
1960
|
+
nulls?: string;
|
|
1961
|
+
}>
|
|
1962
|
+
>
|
|
1687
1963
|
): QueryBuilder<TRecord, TResult>;
|
|
1688
1964
|
}
|
|
1689
1965
|
|
|
@@ -1717,10 +1993,7 @@ export declare namespace Knex {
|
|
|
1717
1993
|
value: Value | QueryBuilder | null
|
|
1718
1994
|
): QueryBuilder<TRecord, TResult>;
|
|
1719
1995
|
|
|
1720
|
-
(raw: Raw): QueryBuilder<
|
|
1721
|
-
TRecord,
|
|
1722
|
-
TResult
|
|
1723
|
-
>;
|
|
1996
|
+
(raw: Raw): QueryBuilder<TRecord, TResult>;
|
|
1724
1997
|
}
|
|
1725
1998
|
|
|
1726
1999
|
interface HavingRange<TRecord extends {} = any, TResult = unknown[]> {
|
|
@@ -1728,12 +2001,18 @@ export declare namespace Knex {
|
|
|
1728
2001
|
columnName: K,
|
|
1729
2002
|
values: readonly DbColumn<TRecord[K]>[]
|
|
1730
2003
|
): QueryBuilder<TRecord, TResult>;
|
|
1731
|
-
(columnName: string, values: readonly Value[]): QueryBuilder<
|
|
2004
|
+
(columnName: string, values: readonly Value[]): QueryBuilder<
|
|
2005
|
+
TRecord,
|
|
2006
|
+
TResult
|
|
2007
|
+
>;
|
|
1732
2008
|
}
|
|
1733
2009
|
|
|
1734
2010
|
// commons
|
|
1735
2011
|
|
|
1736
|
-
interface ColumnNameQueryBuilder<
|
|
2012
|
+
interface ColumnNameQueryBuilder<
|
|
2013
|
+
TRecord extends {} = any,
|
|
2014
|
+
TResult = unknown[]
|
|
2015
|
+
> {
|
|
1737
2016
|
// When all columns are known to be keys of original record,
|
|
1738
2017
|
// we can extend our selection by these columns
|
|
1739
2018
|
(columnName: '*'): QueryBuilder<
|
|
@@ -1748,7 +2027,7 @@ export declare namespace Knex {
|
|
|
1748
2027
|
ResolveTableType<TRecord>,
|
|
1749
2028
|
ColNameUT & string
|
|
1750
2029
|
>[]
|
|
1751
|
-
|
|
2030
|
+
>(
|
|
1752
2031
|
...columnNames: readonly ColNameUT[]
|
|
1753
2032
|
): QueryBuilder<TRecord, TResult2>;
|
|
1754
2033
|
|
|
@@ -1759,7 +2038,7 @@ export declare namespace Knex {
|
|
|
1759
2038
|
ResolveTableType<TRecord>,
|
|
1760
2039
|
ColNameUT & string
|
|
1761
2040
|
>[]
|
|
1762
|
-
|
|
2041
|
+
>(
|
|
1763
2042
|
columnNames: readonly ColNameUT[]
|
|
1764
2043
|
): QueryBuilder<TRecord, TResult2>;
|
|
1765
2044
|
|
|
@@ -1771,7 +2050,7 @@ export declare namespace Knex {
|
|
|
1771
2050
|
SafePartial<TRecord>,
|
|
1772
2051
|
keyof TRecord & string
|
|
1773
2052
|
>[]
|
|
1774
|
-
|
|
2053
|
+
>(
|
|
1775
2054
|
...columnNames: readonly ColumnDescriptor<TRecord, TResult>[]
|
|
1776
2055
|
): QueryBuilder<TRecord, TResult2>;
|
|
1777
2056
|
|
|
@@ -1781,7 +2060,7 @@ export declare namespace Knex {
|
|
|
1781
2060
|
SafePartial<TRecord>,
|
|
1782
2061
|
keyof TRecord & string
|
|
1783
2062
|
>[]
|
|
1784
|
-
|
|
2063
|
+
>(
|
|
1785
2064
|
columnNames: readonly ColumnDescriptor<TRecord, TResult>[]
|
|
1786
2065
|
): QueryBuilder<TRecord, TResult2>;
|
|
1787
2066
|
}
|
|
@@ -1793,18 +2072,15 @@ export declare namespace Knex {
|
|
|
1793
2072
|
sql: string,
|
|
1794
2073
|
bindings?: readonly RawBinding[] | ValueDict | RawBinding
|
|
1795
2074
|
): QueryBuilder<TRecord, TResult2>;
|
|
1796
|
-
<TResult2 = TResult>(raw: Raw<TResult2>): QueryBuilder<
|
|
1797
|
-
TRecord,
|
|
1798
|
-
TResult2
|
|
1799
|
-
>;
|
|
2075
|
+
<TResult2 = TResult>(raw: Raw<TResult2>): QueryBuilder<TRecord, TResult2>;
|
|
1800
2076
|
}
|
|
1801
2077
|
|
|
1802
2078
|
// Raw
|
|
1803
2079
|
|
|
1804
2080
|
interface Raw<TResult = any>
|
|
1805
2081
|
extends events.EventEmitter,
|
|
1806
|
-
|
|
1807
|
-
timeout(ms: number, options?: {cancel?: boolean}): Raw<TResult>;
|
|
2082
|
+
ChainableInterface<ResolveResult<TResult>> {
|
|
2083
|
+
timeout(ms: number, options?: { cancel?: boolean }): Raw<TResult>;
|
|
1808
2084
|
wrap<TResult2 = TResult>(before: string, after: string): Raw<TResult>;
|
|
1809
2085
|
toSQL(): Sql;
|
|
1810
2086
|
queryContext(context: any): Raw<TResult>;
|
|
@@ -1813,8 +2089,14 @@ export declare namespace Knex {
|
|
|
1813
2089
|
|
|
1814
2090
|
interface RawBuilder<TRecord extends {} = any, TResult = any> {
|
|
1815
2091
|
<TResult2 = TResult>(value: Value): Raw<TResult2>;
|
|
1816
|
-
<TResult2 = TResult>(
|
|
1817
|
-
|
|
2092
|
+
<TResult2 = TResult>(
|
|
2093
|
+
sql: string,
|
|
2094
|
+
...bindings: readonly RawBinding[]
|
|
2095
|
+
): Raw<TResult2>;
|
|
2096
|
+
<TResult2 = TResult>(
|
|
2097
|
+
sql: string,
|
|
2098
|
+
bindings: readonly RawBinding[] | ValueDict
|
|
2099
|
+
): Raw<TResult2>;
|
|
1818
2100
|
}
|
|
1819
2101
|
|
|
1820
2102
|
const RefMemberTag: unique symbol;
|
|
@@ -1832,21 +2114,26 @@ export declare namespace Knex {
|
|
|
1832
2114
|
// Because unique symbol is used here, there is no way to actually
|
|
1833
2115
|
// access this at runtime
|
|
1834
2116
|
[RefMemberTag]: {
|
|
1835
|
-
src: TSrc
|
|
1836
|
-
mapping: TMapping
|
|
2117
|
+
src: TSrc;
|
|
2118
|
+
mapping: TMapping;
|
|
1837
2119
|
};
|
|
1838
2120
|
withSchema(schema: string): this;
|
|
1839
|
-
as<TAlias extends string>(
|
|
2121
|
+
as<TAlias extends string>(
|
|
2122
|
+
alias: TAlias
|
|
2123
|
+
): Ref<TSrc, { [K in TAlias]: TSrc }>;
|
|
1840
2124
|
}
|
|
1841
2125
|
|
|
1842
2126
|
interface RefBuilder {
|
|
1843
|
-
<TSrc extends string>(src: TSrc): Ref<TSrc, {[K in TSrc]: TSrc}>;
|
|
2127
|
+
<TSrc extends string>(src: TSrc): Ref<TSrc, { [K in TSrc]: TSrc }>;
|
|
1844
2128
|
}
|
|
1845
2129
|
|
|
1846
|
-
interface BatchInsertBuilder<TRecord extends {} = any, TResult = number[]>
|
|
2130
|
+
interface BatchInsertBuilder<TRecord extends {} = any, TResult = number[]>
|
|
2131
|
+
extends Promise<ResolveResult<TResult>> {
|
|
1847
2132
|
transacting(trx: Transaction): this;
|
|
1848
2133
|
// see returning methods from QueryInterface
|
|
1849
|
-
returning(
|
|
2134
|
+
returning(
|
|
2135
|
+
column: '*'
|
|
2136
|
+
): BatchInsertBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
|
|
1850
2137
|
returning<
|
|
1851
2138
|
TKey extends StrKey<ResolveTableType<TRecord>>,
|
|
1852
2139
|
TResult2 = DeferredKeySelection.Augment<
|
|
@@ -1860,7 +2147,11 @@ export declare namespace Knex {
|
|
|
1860
2147
|
returning<
|
|
1861
2148
|
TKey extends StrKey<ResolveTableType<TRecord>>,
|
|
1862
2149
|
TResult2 = DeferredKeySelection.SetSingle<
|
|
1863
|
-
DeferredKeySelection.Augment<
|
|
2150
|
+
DeferredKeySelection.Augment<
|
|
2151
|
+
UnwrapArrayMember<TResult>,
|
|
2152
|
+
ResolveTableType<TRecord>,
|
|
2153
|
+
TKey
|
|
2154
|
+
>,
|
|
1864
2155
|
false
|
|
1865
2156
|
>[]
|
|
1866
2157
|
>(
|
|
@@ -1868,7 +2159,9 @@ export declare namespace Knex {
|
|
|
1868
2159
|
): BatchInsertBuilder<TRecord, TResult2>;
|
|
1869
2160
|
// if data with specific type passed, exclude this method
|
|
1870
2161
|
returning<TResult2 = SafePartial<TRecord>[]>(
|
|
1871
|
-
column: unknown extends TRecord
|
|
2162
|
+
column: unknown extends TRecord
|
|
2163
|
+
? string | readonly (string | Raw)[] | Raw
|
|
2164
|
+
: never
|
|
1872
2165
|
): BatchInsertBuilder<TRecord, TResult2>;
|
|
1873
2166
|
}
|
|
1874
2167
|
|
|
@@ -1887,20 +2180,21 @@ export declare namespace Knex {
|
|
|
1887
2180
|
...args: any[]
|
|
1888
2181
|
) => void;
|
|
1889
2182
|
|
|
1890
|
-
interface QueryBuilder<
|
|
1891
|
-
TRecord extends {} = any,
|
|
1892
|
-
TResult = any
|
|
1893
|
-
>
|
|
2183
|
+
interface QueryBuilder<TRecord extends {} = any, TResult = any>
|
|
1894
2184
|
extends QueryInterface<TRecord, TResult>,
|
|
1895
|
-
|
|
2185
|
+
ChainableInterface<ResolveResult<TResult>> {
|
|
1896
2186
|
client: Client;
|
|
1897
2187
|
or: QueryBuilder<TRecord, TResult>;
|
|
1898
2188
|
not: QueryBuilder<TRecord, TResult>;
|
|
1899
2189
|
and: QueryBuilder<TRecord, TResult>;
|
|
1900
2190
|
|
|
1901
2191
|
// TODO: Promise?
|
|
1902
|
-
columnInfo(
|
|
1903
|
-
|
|
2192
|
+
columnInfo(
|
|
2193
|
+
column: keyof DeferredKeySelection.Resolve<TRecord>
|
|
2194
|
+
): Promise<ColumnInfo>;
|
|
2195
|
+
columnInfo(): Promise<
|
|
2196
|
+
Record<keyof DeferredKeySelection.Resolve<TRecord>, ColumnInfo>
|
|
2197
|
+
>;
|
|
1904
2198
|
|
|
1905
2199
|
forUpdate(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
|
1906
2200
|
forUpdate(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
|
@@ -1909,7 +2203,9 @@ export declare namespace Knex {
|
|
|
1909
2203
|
forShare(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
|
1910
2204
|
|
|
1911
2205
|
forNoKeyUpdate(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
|
1912
|
-
forNoKeyUpdate(
|
|
2206
|
+
forNoKeyUpdate(
|
|
2207
|
+
tableNames: readonly string[]
|
|
2208
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1913
2209
|
|
|
1914
2210
|
forKeyShare(...tableNames: string[]): QueryBuilder<TRecord, TResult>;
|
|
1915
2211
|
forKeyShare(tableNames: readonly string[]): QueryBuilder<TRecord, TResult>;
|
|
@@ -1925,7 +2221,10 @@ export declare namespace Knex {
|
|
|
1925
2221
|
queryContext(): any;
|
|
1926
2222
|
|
|
1927
2223
|
clone(): QueryBuilder<TRecord, TResult>;
|
|
1928
|
-
timeout(
|
|
2224
|
+
timeout(
|
|
2225
|
+
ms: number,
|
|
2226
|
+
options?: { cancel?: boolean }
|
|
2227
|
+
): QueryBuilder<TRecord, TResult>;
|
|
1929
2228
|
}
|
|
1930
2229
|
|
|
1931
2230
|
interface Sql {
|
|
@@ -1945,16 +2244,20 @@ export declare namespace Knex {
|
|
|
1945
2244
|
// Chainable interface
|
|
1946
2245
|
//
|
|
1947
2246
|
|
|
1948
|
-
type ExposedPromiseKeys =
|
|
1949
|
-
| "then"
|
|
1950
|
-
| "catch"
|
|
1951
|
-
| "finally";
|
|
2247
|
+
type ExposedPromiseKeys = 'then' | 'catch' | 'finally';
|
|
1952
2248
|
|
|
1953
2249
|
interface StringTagSupport {
|
|
1954
2250
|
readonly [Symbol.toStringTag]: string;
|
|
1955
2251
|
}
|
|
1956
|
-
interface ChainableInterface<T = any>
|
|
1957
|
-
|
|
2252
|
+
interface ChainableInterface<T = any>
|
|
2253
|
+
extends Pick<Promise<T>, keyof Promise<T> & ExposedPromiseKeys>,
|
|
2254
|
+
StringTagSupport {
|
|
2255
|
+
generateDdlCommands(): Promise<{
|
|
2256
|
+
pre: string[];
|
|
2257
|
+
sql: string[];
|
|
2258
|
+
check: string | null;
|
|
2259
|
+
post: string[];
|
|
2260
|
+
}>;
|
|
1958
2261
|
toQuery(): string;
|
|
1959
2262
|
options(options: Readonly<{ [key: string]: any }>): this;
|
|
1960
2263
|
connection(connection: any): this;
|
|
@@ -1965,7 +2268,9 @@ export declare namespace Knex {
|
|
|
1965
2268
|
options: Readonly<{ [key: string]: any }>,
|
|
1966
2269
|
handler: (readable: stream.PassThrough) => any
|
|
1967
2270
|
): Promise<any>;
|
|
1968
|
-
stream(
|
|
2271
|
+
stream(
|
|
2272
|
+
options?: Readonly<{ [key: string]: any }>
|
|
2273
|
+
): stream.PassThrough & AsyncIterable<ArrayMember<T>>;
|
|
1969
2274
|
pipe<T extends NodeJS.WritableStream>(
|
|
1970
2275
|
writable: T,
|
|
1971
2276
|
options?: Readonly<{ [key: string]: any }>
|
|
@@ -1974,7 +2279,12 @@ export declare namespace Knex {
|
|
|
1974
2279
|
}
|
|
1975
2280
|
|
|
1976
2281
|
// Not all of these are possible for all drivers, notably, sqlite doesn't support any of these
|
|
1977
|
-
type IsolationLevels =
|
|
2282
|
+
type IsolationLevels =
|
|
2283
|
+
| 'read uncommitted'
|
|
2284
|
+
| 'read committed'
|
|
2285
|
+
| 'snapshot'
|
|
2286
|
+
| 'repeatable read'
|
|
2287
|
+
| 'serializable';
|
|
1978
2288
|
interface TransactionConfig {
|
|
1979
2289
|
isolationLevel?: IsolationLevels;
|
|
1980
2290
|
userParams?: Record<string, any>;
|
|
@@ -1993,9 +2303,7 @@ export declare namespace Knex {
|
|
|
1993
2303
|
status: any,
|
|
1994
2304
|
value: any
|
|
1995
2305
|
): QueryBuilder<TRecord, TResult>;
|
|
1996
|
-
savepoint<T = any>(
|
|
1997
|
-
transactionScope: (trx: Transaction) => any
|
|
1998
|
-
): Promise<T>;
|
|
2306
|
+
savepoint<T = any>(transactionScope: (trx: Transaction) => any): Promise<T>;
|
|
1999
2307
|
commit(value?: any): QueryBuilder<TRecord, TResult>;
|
|
2000
2308
|
rollback(error?: any): QueryBuilder<TRecord, TResult>;
|
|
2001
2309
|
}
|
|
@@ -2020,7 +2328,10 @@ export declare namespace Knex {
|
|
|
2020
2328
|
viewName: string,
|
|
2021
2329
|
callback: (viewBuilder: ViewBuilder) => any
|
|
2022
2330
|
): SchemaBuilder;
|
|
2023
|
-
refreshMaterializedView(
|
|
2331
|
+
refreshMaterializedView(
|
|
2332
|
+
viewName: string,
|
|
2333
|
+
concurrently?: boolean
|
|
2334
|
+
): SchemaBuilder;
|
|
2024
2335
|
dropView(viewName: string): SchemaBuilder;
|
|
2025
2336
|
dropViewIfExists(viewName: string): SchemaBuilder;
|
|
2026
2337
|
dropMaterializedView(viewName: string): SchemaBuilder;
|
|
@@ -2114,19 +2425,36 @@ export declare namespace Knex {
|
|
|
2114
2425
|
): ColumnBuilder;
|
|
2115
2426
|
boolean(columnName: string): ColumnBuilder;
|
|
2116
2427
|
date(columnName: string): ColumnBuilder;
|
|
2117
|
-
dateTime(
|
|
2118
|
-
|
|
2428
|
+
dateTime(
|
|
2429
|
+
columnName: string,
|
|
2430
|
+
options?: Readonly<{ useTz?: boolean; precision?: number }>
|
|
2431
|
+
): ColumnBuilder;
|
|
2432
|
+
datetime(
|
|
2433
|
+
columnName: string,
|
|
2434
|
+
options?: Readonly<{ useTz?: boolean; precision?: number }>
|
|
2435
|
+
): ColumnBuilder;
|
|
2119
2436
|
time(columnName: string): ColumnBuilder;
|
|
2120
|
-
timestamp(
|
|
2437
|
+
timestamp(
|
|
2438
|
+
columnName: string,
|
|
2439
|
+
options?: Readonly<{ useTz?: boolean; precision?: number }>
|
|
2440
|
+
): ColumnBuilder;
|
|
2121
2441
|
/** @deprecated */
|
|
2122
|
-
timestamp(
|
|
2442
|
+
timestamp(
|
|
2443
|
+
columnName: string,
|
|
2444
|
+
withoutTz?: boolean,
|
|
2445
|
+
precision?: number
|
|
2446
|
+
): ColumnBuilder;
|
|
2123
2447
|
timestamps(
|
|
2124
2448
|
useTimestamps?: boolean,
|
|
2125
2449
|
defaultToNow?: boolean,
|
|
2126
2450
|
useCamelCase?: boolean
|
|
2127
2451
|
): ColumnBuilder;
|
|
2128
2452
|
timestamps(
|
|
2129
|
-
options?: Readonly<{
|
|
2453
|
+
options?: Readonly<{
|
|
2454
|
+
useTimestamps?: boolean;
|
|
2455
|
+
defaultToNow?: boolean;
|
|
2456
|
+
useCamelCase?: boolean;
|
|
2457
|
+
}>
|
|
2130
2458
|
): void;
|
|
2131
2459
|
geometry(columnName: string): ColumnBuilder;
|
|
2132
2460
|
geography(columnName: string): ColumnBuilder;
|
|
@@ -2134,22 +2462,34 @@ export declare namespace Knex {
|
|
|
2134
2462
|
binary(columnName: string, length?: number): ColumnBuilder;
|
|
2135
2463
|
enum(
|
|
2136
2464
|
columnName: string,
|
|
2137
|
-
values:
|
|
2465
|
+
values: readonly Value[] | null,
|
|
2138
2466
|
options?: EnumOptions
|
|
2139
2467
|
): ColumnBuilder;
|
|
2140
2468
|
enu(
|
|
2141
2469
|
columnName: string,
|
|
2142
|
-
values:
|
|
2470
|
+
values: readonly Value[] | null,
|
|
2143
2471
|
options?: EnumOptions
|
|
2144
2472
|
): ColumnBuilder;
|
|
2145
2473
|
json(columnName: string): ColumnBuilder;
|
|
2146
2474
|
jsonb(columnName: string): ColumnBuilder;
|
|
2147
|
-
uuid(
|
|
2475
|
+
uuid(
|
|
2476
|
+
columnName: string,
|
|
2477
|
+
options?: Readonly<{ useBinaryUuid?: boolean; primaryKey?: boolean }>
|
|
2478
|
+
): ColumnBuilder;
|
|
2148
2479
|
comment(val: string): void;
|
|
2149
2480
|
specificType(columnName: string, type: string): ColumnBuilder;
|
|
2150
|
-
primary(
|
|
2481
|
+
primary(
|
|
2482
|
+
columnNames: readonly string[],
|
|
2483
|
+
options?: Readonly<{
|
|
2484
|
+
constraintName?: string;
|
|
2485
|
+
deferrable?: deferrableType;
|
|
2486
|
+
}>
|
|
2487
|
+
): TableBuilder;
|
|
2151
2488
|
/** @deprecated */
|
|
2152
|
-
primary(
|
|
2489
|
+
primary(
|
|
2490
|
+
columnNames: readonly string[],
|
|
2491
|
+
constraintName?: string
|
|
2492
|
+
): TableBuilder;
|
|
2153
2493
|
index(
|
|
2154
2494
|
columnNames: string | readonly (string | Raw)[],
|
|
2155
2495
|
indexName?: string,
|
|
@@ -2158,23 +2498,51 @@ export declare namespace Knex {
|
|
|
2158
2498
|
index(
|
|
2159
2499
|
columnNames: string | readonly (string | Raw)[],
|
|
2160
2500
|
indexName?: string,
|
|
2161
|
-
options?: Readonly<{
|
|
2501
|
+
options?: Readonly<{
|
|
2502
|
+
indexType?: string;
|
|
2503
|
+
storageEngineIndexType?: storageEngineIndexType;
|
|
2504
|
+
predicate?: QueryBuilder;
|
|
2505
|
+
}>
|
|
2162
2506
|
): TableBuilder;
|
|
2163
2507
|
setNullable(column: string): TableBuilder;
|
|
2164
2508
|
dropNullable(column: string): TableBuilder;
|
|
2165
|
-
unique(
|
|
2509
|
+
unique(
|
|
2510
|
+
columnNames: readonly (string | Raw)[],
|
|
2511
|
+
options?: Readonly<{
|
|
2512
|
+
indexName?: string;
|
|
2513
|
+
storageEngineIndexType?: string;
|
|
2514
|
+
deferrable?: deferrableType;
|
|
2515
|
+
useConstraint?: boolean;
|
|
2516
|
+
}>
|
|
2517
|
+
): TableBuilder;
|
|
2166
2518
|
/** @deprecated */
|
|
2167
|
-
unique(
|
|
2519
|
+
unique(
|
|
2520
|
+
columnNames: readonly (string | Raw)[],
|
|
2521
|
+
indexName?: string
|
|
2522
|
+
): TableBuilder;
|
|
2168
2523
|
foreign(column: string, foreignKeyName?: string): ForeignConstraintBuilder;
|
|
2169
2524
|
foreign(
|
|
2170
2525
|
columns: readonly string[],
|
|
2171
2526
|
foreignKeyName?: string
|
|
2172
2527
|
): MultikeyForeignConstraintBuilder;
|
|
2173
|
-
check(
|
|
2174
|
-
|
|
2175
|
-
|
|
2528
|
+
check(
|
|
2529
|
+
checkPredicate: string,
|
|
2530
|
+
bindings?: Record<string, any>,
|
|
2531
|
+
constraintName?: string
|
|
2532
|
+
): TableBuilder;
|
|
2533
|
+
dropForeign(
|
|
2534
|
+
columnNames: string | readonly string[],
|
|
2535
|
+
foreignKeyName?: string
|
|
2536
|
+
): TableBuilder;
|
|
2537
|
+
dropUnique(
|
|
2538
|
+
columnNames: readonly (string | Raw)[],
|
|
2539
|
+
indexName?: string
|
|
2540
|
+
): TableBuilder;
|
|
2176
2541
|
dropPrimary(constraintName?: string): TableBuilder;
|
|
2177
|
-
dropIndex(
|
|
2542
|
+
dropIndex(
|
|
2543
|
+
columnNames: string | readonly (string | Raw)[],
|
|
2544
|
+
indexName?: string
|
|
2545
|
+
): TableBuilder;
|
|
2178
2546
|
dropTimestamps(useCamelCase?: boolean): TableBuilder;
|
|
2179
2547
|
dropChecks(checkConstraintNames: string | string[]): TableBuilder;
|
|
2180
2548
|
queryContext(context: any): TableBuilder;
|
|
@@ -2213,11 +2581,18 @@ export declare namespace Knex {
|
|
|
2213
2581
|
|
|
2214
2582
|
interface ColumnBuilder {
|
|
2215
2583
|
index(indexName?: string): ColumnBuilder;
|
|
2216
|
-
primary(
|
|
2584
|
+
primary(
|
|
2585
|
+
options?: Readonly<{
|
|
2586
|
+
constraintName?: string;
|
|
2587
|
+
deferrable?: deferrableType;
|
|
2588
|
+
}>
|
|
2589
|
+
): ColumnBuilder;
|
|
2217
2590
|
/** @deprecated */
|
|
2218
2591
|
primary(constraintName?: string): ColumnBuilder;
|
|
2219
2592
|
|
|
2220
|
-
unique(
|
|
2593
|
+
unique(
|
|
2594
|
+
options?: Readonly<{ indexName?: string; deferrable?: deferrableType }>
|
|
2595
|
+
): ColumnBuilder;
|
|
2221
2596
|
/** @deprecated */
|
|
2222
2597
|
unique(indexName?: string): ColumnBuilder;
|
|
2223
2598
|
references(columnName: string): ReferencingColumnBuilder;
|
|
@@ -2226,7 +2601,9 @@ export declare namespace Knex {
|
|
|
2226
2601
|
notNullable(): ColumnBuilder;
|
|
2227
2602
|
nullable(): ColumnBuilder;
|
|
2228
2603
|
comment(value: string): ColumnBuilder;
|
|
2229
|
-
alter(
|
|
2604
|
+
alter(
|
|
2605
|
+
options?: Readonly<{ alterNullable?: boolean; alterType?: boolean }>
|
|
2606
|
+
): ColumnBuilder;
|
|
2230
2607
|
queryContext(context: any): ColumnBuilder;
|
|
2231
2608
|
after(columnName: string): ColumnBuilder;
|
|
2232
2609
|
first(): ColumnBuilder;
|
|
@@ -2234,8 +2611,15 @@ export declare namespace Knex {
|
|
|
2234
2611
|
checkNegative(constraintName?: string): ColumnBuilder;
|
|
2235
2612
|
checkIn(values: string[], constraintName?: string): ColumnBuilder;
|
|
2236
2613
|
checkNotIn(values: string[], constraintName?: string): ColumnBuilder;
|
|
2237
|
-
checkBetween(
|
|
2238
|
-
|
|
2614
|
+
checkBetween(
|
|
2615
|
+
values: any[] | any[][],
|
|
2616
|
+
constraintName?: string
|
|
2617
|
+
): ColumnBuilder;
|
|
2618
|
+
checkLength(
|
|
2619
|
+
operator: lengthOperator,
|
|
2620
|
+
length: number,
|
|
2621
|
+
constraintName?: string
|
|
2622
|
+
): ColumnBuilder;
|
|
2239
2623
|
checkRegex(regex: string, constraintName?: string): ColumnBuilder;
|
|
2240
2624
|
}
|
|
2241
2625
|
|
|
@@ -2250,7 +2634,7 @@ export declare namespace Knex {
|
|
|
2250
2634
|
interface PostgreSqlColumnBuilder extends ColumnBuilder {
|
|
2251
2635
|
index(
|
|
2252
2636
|
indexName?: string,
|
|
2253
|
-
options?: Readonly<{indexType?: string
|
|
2637
|
+
options?: Readonly<{ indexType?: string; predicate?: QueryBuilder }>
|
|
2254
2638
|
): ColumnBuilder;
|
|
2255
2639
|
index(indexName?: string, indexType?: string): ColumnBuilder;
|
|
2256
2640
|
}
|
|
@@ -2258,28 +2642,33 @@ export declare namespace Knex {
|
|
|
2258
2642
|
interface SqlLiteColumnBuilder extends ColumnBuilder {
|
|
2259
2643
|
index(
|
|
2260
2644
|
indexName?: string,
|
|
2261
|
-
options?: Readonly<{predicate?: QueryBuilder}>
|
|
2645
|
+
options?: Readonly<{ predicate?: QueryBuilder }>
|
|
2262
2646
|
): ColumnBuilder;
|
|
2263
2647
|
}
|
|
2264
2648
|
|
|
2265
2649
|
interface MsSqlColumnBuilder extends ColumnBuilder {
|
|
2266
2650
|
index(
|
|
2267
2651
|
indexName?: string,
|
|
2268
|
-
options?: Readonly<{predicate?: QueryBuilder}>
|
|
2652
|
+
options?: Readonly<{ predicate?: QueryBuilder }>
|
|
2269
2653
|
): ColumnBuilder;
|
|
2270
2654
|
}
|
|
2271
2655
|
|
|
2272
2656
|
interface MySqlColumnBuilder extends ColumnBuilder {
|
|
2273
2657
|
index(
|
|
2274
2658
|
indexName?: string,
|
|
2275
|
-
options?: Readonly<{
|
|
2659
|
+
options?: Readonly<{
|
|
2660
|
+
indexType?: string;
|
|
2661
|
+
storageEngineIndexType?: storageEngineIndexType;
|
|
2662
|
+
}>
|
|
2276
2663
|
): ColumnBuilder;
|
|
2277
2664
|
}
|
|
2278
2665
|
|
|
2279
2666
|
// patched ColumnBuilder methods to return ReferencingColumnBuilder with new methods
|
|
2280
2667
|
// relies on ColumnBuilder returning only ColumnBuilder
|
|
2281
2668
|
type ReferencingColumnBuilder = {
|
|
2282
|
-
[K in keyof ColumnBuilder]: (
|
|
2669
|
+
[K in keyof ColumnBuilder]: (
|
|
2670
|
+
...args: Parameters<ColumnBuilder[K]>
|
|
2671
|
+
) => ReferencingColumnBuilder;
|
|
2283
2672
|
} & {
|
|
2284
2673
|
inTable(tableName: string): ReferencingColumnBuilder;
|
|
2285
2674
|
deferrable(type: deferrableType): ReferencingColumnBuilder;
|
|
@@ -2340,9 +2729,11 @@ export declare namespace Knex {
|
|
|
2340
2729
|
| Sqlite3ConnectionConfig
|
|
2341
2730
|
| SocketConnectionConfig;
|
|
2342
2731
|
|
|
2343
|
-
type ConnectionConfigProvider
|
|
2344
|
-
|
|
2345
|
-
|
|
2732
|
+
type ConnectionConfigProvider =
|
|
2733
|
+
| SyncConnectionConfigProvider
|
|
2734
|
+
| AsyncConnectionConfigProvider;
|
|
2735
|
+
type SyncConnectionConfigProvider = () => StaticConnectionConfig;
|
|
2736
|
+
type AsyncConnectionConfigProvider = () => Promise<StaticConnectionConfig>;
|
|
2346
2737
|
|
|
2347
2738
|
interface ConnectionConfig {
|
|
2348
2739
|
host: string;
|
|
@@ -2486,7 +2877,12 @@ export declare namespace Knex {
|
|
|
2486
2877
|
abortTransactionOnError?: boolean;
|
|
2487
2878
|
trustedConnection?: boolean;
|
|
2488
2879
|
enableArithAbort?: boolean;
|
|
2489
|
-
isolationLevel?:
|
|
2880
|
+
isolationLevel?:
|
|
2881
|
+
| 'READ_UNCOMMITTED'
|
|
2882
|
+
| 'READ_COMMITTED'
|
|
2883
|
+
| 'REPEATABLE_READ'
|
|
2884
|
+
| 'SERIALIZABLE'
|
|
2885
|
+
| 'SNAPSHOT';
|
|
2490
2886
|
maxRetriesOnTransientErrors?: number;
|
|
2491
2887
|
multiSubnetFailover?: boolean;
|
|
2492
2888
|
packetSize?: number;
|
|
@@ -2574,11 +2970,13 @@ export declare namespace Knex {
|
|
|
2574
2970
|
// Config object for mysql2: https://github.com/sidorares/node-mysql2/blob/master/lib/connection_config.js
|
|
2575
2971
|
// Some options for connection pooling and MySQL server API are excluded.
|
|
2576
2972
|
interface MySql2ConnectionConfig extends MySqlConnectionConfig {
|
|
2577
|
-
authPlugins?: {
|
|
2973
|
+
authPlugins?: {
|
|
2974
|
+
[pluginName: string]: (pluginMetadata: any) => (pluginData: any) => any;
|
|
2975
|
+
};
|
|
2578
2976
|
authSwitchHandler?: (data: any, callback: () => void) => any;
|
|
2579
2977
|
charsetNumber?: number;
|
|
2580
2978
|
compress?: boolean;
|
|
2581
|
-
connectAttributes?: {[attrNames: string]: any};
|
|
2979
|
+
connectAttributes?: { [attrNames: string]: any };
|
|
2582
2980
|
enableKeepAlive?: boolean;
|
|
2583
2981
|
keepAliveInitialDelay?: number;
|
|
2584
2982
|
maxPreparedStatements?: number;
|
|
@@ -2628,7 +3026,7 @@ export declare namespace Knex {
|
|
|
2628
3026
|
type PgGetTypeParser = (oid: number, format: string) => any;
|
|
2629
3027
|
|
|
2630
3028
|
interface PgCustomTypesConfig {
|
|
2631
|
-
|
|
3029
|
+
getTypeParser: PgGetTypeParser;
|
|
2632
3030
|
}
|
|
2633
3031
|
|
|
2634
3032
|
type RedshiftConnectionConfig = PgConnectionConfig;
|
|
@@ -2786,7 +3184,12 @@ export declare namespace Knex {
|
|
|
2786
3184
|
queryCompiler(builder: any): any;
|
|
2787
3185
|
schemaBuilder(): SchemaBuilder;
|
|
2788
3186
|
schemaCompiler(builder: SchemaBuilder): any;
|
|
2789
|
-
tableBuilder(
|
|
3187
|
+
tableBuilder(
|
|
3188
|
+
type: any,
|
|
3189
|
+
tableName: any,
|
|
3190
|
+
tableNameLike: any,
|
|
3191
|
+
fn: any
|
|
3192
|
+
): TableBuilder;
|
|
2790
3193
|
tableCompiler(tableBuilder: any): any;
|
|
2791
3194
|
columnBuilder(tableBuilder: any, type: any, args: any): ColumnBuilder;
|
|
2792
3195
|
columnCompiler(tableBuilder: any, columnBuilder: any): any;
|