pqb 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +832 -793
- package/dist/index.esm.js +197 -150
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +197 -150
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/columnSchema/columnsSchema.ts +15 -4
- package/src/columnSchema/number.ts +3 -0
- package/src/queryMethods/aggregate.test.ts +2 -2
- package/src/queryMethods/insert.test.ts +217 -205
- package/src/queryMethods/insert.ts +383 -273
- package/src/queryMethods/update.test.ts +3 -3
- package/src/queryMethods/upsert.test.ts +1 -1
- package/src/queryMethods/window.test.ts +2 -2
- package/src/relations.ts +5 -2
- package/src/utils.test.ts +37 -0
- package/src/utils.ts +9 -0
package/dist/index.d.ts
CHANGED
|
@@ -230,59 +230,314 @@ declare class WhereQueryBuilder<Q extends QueryBase = QueryBase> extends Where i
|
|
|
230
230
|
clone<T extends this>(this: T): T;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
declare type
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
233
|
+
declare type AggregateArg<T extends Query> = Expression<T> | Record<string, Expression<T>> | [Expression<T>, string];
|
|
234
|
+
declare type AggregateOptions<T extends Query = Query, As extends string | undefined = any> = {
|
|
235
|
+
as?: As;
|
|
236
|
+
distinct?: boolean;
|
|
237
|
+
order?: OrderArg<T> | OrderArg<T>[];
|
|
238
|
+
filter?: WhereArg<T>;
|
|
239
|
+
filterOr?: WhereArg<T>[];
|
|
240
|
+
withinGroup?: boolean;
|
|
241
|
+
over?: T['windows'][number] | WindowArgDeclaration<T>;
|
|
242
|
+
};
|
|
243
|
+
declare type Aggregate1ArgumentTypes<T extends Query = Query, C extends ColumnType = ColumnType> = {
|
|
244
|
+
count: Expression<T, C>;
|
|
245
|
+
avg: NumberExpression<T, C>;
|
|
246
|
+
min: Expression<T, C>;
|
|
247
|
+
max: Expression<T, C>;
|
|
248
|
+
sum: NumberExpression<T, C>;
|
|
249
|
+
bitAnd: NumberExpression<T, C>;
|
|
250
|
+
bitOr: NumberExpression<T, C>;
|
|
251
|
+
boolAnd: BooleanExpression<T, C>;
|
|
252
|
+
boolOr: BooleanExpression<T, C>;
|
|
253
|
+
every: BooleanExpression<T, C>;
|
|
254
|
+
jsonAgg: Expression<T, C>;
|
|
255
|
+
jsonbAgg: Expression<T, C>;
|
|
256
|
+
xmlAgg: Expression<T, C>;
|
|
257
|
+
};
|
|
258
|
+
declare const aggregate1FunctionNames: {
|
|
259
|
+
readonly count: "count";
|
|
260
|
+
readonly avg: "avg";
|
|
261
|
+
readonly min: "min";
|
|
262
|
+
readonly max: "max";
|
|
263
|
+
readonly sum: "sum";
|
|
264
|
+
readonly bitAnd: "bit_and";
|
|
265
|
+
readonly bitOr: "bit_or";
|
|
266
|
+
readonly boolAnd: "bool_and";
|
|
267
|
+
readonly boolOr: "bool_or";
|
|
268
|
+
readonly every: "every";
|
|
269
|
+
readonly jsonAgg: "json_agg";
|
|
270
|
+
readonly jsonbAgg: "jsonb_agg";
|
|
271
|
+
readonly xmlAgg: "xmlagg";
|
|
272
|
+
};
|
|
273
|
+
declare type SelectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType> = AddQuerySelect<T, Record<CoalesceString<As, Func>, Value>>;
|
|
274
|
+
declare type AT1<T extends Query> = Aggregate1ArgumentTypes<T>;
|
|
275
|
+
declare type WindowFunctionOptions<T extends Query = Query, As extends string | undefined = any> = {
|
|
276
|
+
as?: As;
|
|
277
|
+
} & WindowArgDeclaration<T>;
|
|
278
|
+
declare class Aggregate {
|
|
279
|
+
selectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType>(this: T, functionName: Func, arg: AggregateArg<T>, options?: AggregateOptions<T, As>): SelectAgg<T, Func, As, Value>;
|
|
280
|
+
_selectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType>(this: T, functionName: Func, arg: AggregateArg<T>, options?: AggregateOptions<T, As>, columnType?: ColumnType): SelectAgg<T, Func, As, Value>;
|
|
281
|
+
count<T extends Query>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T>): SetQueryReturnsValue<T, NumberColumn>;
|
|
282
|
+
_count<T extends Query>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T>): SetQueryReturnsValue<T, NumberColumn>;
|
|
283
|
+
selectCount<T extends Query, As extends string | undefined = undefined>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T, As>): SelectAgg<T, 'count', As, NumberColumn>;
|
|
284
|
+
_selectCount<T extends Query, As extends string | undefined = undefined>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T, As>): SelectAgg<T, 'count', As, NumberColumn>;
|
|
285
|
+
avg<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['avg'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
286
|
+
_avg<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['avg'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
287
|
+
selectAvg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'avg', As, NullableColumn<NumberColumn>>;
|
|
288
|
+
_selectAvg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'avg', As, NullableColumn<NumberColumn>>;
|
|
289
|
+
min<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['min'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
290
|
+
_min<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['min'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
291
|
+
selectMin<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'min', As, NullableColumn<NumberColumn>>;
|
|
292
|
+
_selectMin<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'min', As, NullableColumn<NumberColumn>>;
|
|
293
|
+
max<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['max'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
294
|
+
_max<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['max'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
295
|
+
selectMax<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'max', As, NullableColumn<NumberColumn>>;
|
|
296
|
+
_selectMax<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'max', As, NullableColumn<NumberColumn>>;
|
|
297
|
+
sum<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['sum'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
298
|
+
_sum<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['sum'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
299
|
+
selectSum<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'sum', As, NullableColumn<NumberColumn>>;
|
|
300
|
+
_selectSum<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'sum', As, NullableColumn<NumberColumn>>;
|
|
301
|
+
bitAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
302
|
+
_bitAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
303
|
+
selectBitAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_and', As, NullableColumn<NumberColumn>>;
|
|
304
|
+
_selectBitAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_and', As, NullableColumn<NumberColumn>>;
|
|
305
|
+
bitOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
306
|
+
_bitOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
307
|
+
selectBitOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_or', As, NullableColumn<NumberColumn>>;
|
|
308
|
+
_selectBitOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_or', As, NullableColumn<NumberColumn>>;
|
|
309
|
+
boolAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
310
|
+
_boolAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
311
|
+
selectBoolAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_and', As, NullableColumn<BooleanColumn>>;
|
|
312
|
+
_selectBoolAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_and', As, NullableColumn<BooleanColumn>>;
|
|
313
|
+
boolOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
314
|
+
_boolOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
315
|
+
selectBoolOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_or', As, NullableColumn<BooleanColumn>>;
|
|
316
|
+
_selectBoolOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_or', As, NullableColumn<BooleanColumn>>;
|
|
317
|
+
every<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['every'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
318
|
+
_every<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['every'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
319
|
+
selectEvery<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'every', As, NullableColumn<BooleanColumn>>;
|
|
320
|
+
_selectEvery<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'every', As, NullableColumn<BooleanColumn>>;
|
|
321
|
+
jsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
322
|
+
_jsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
323
|
+
selectJsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
324
|
+
_selectJsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
325
|
+
jsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
326
|
+
_jsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
327
|
+
selectJsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
328
|
+
_selectJsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
329
|
+
xmlAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['xmlAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
330
|
+
_xmlAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['xmlAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
331
|
+
selectXmlAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Aggregate1ArgumentTypes<T>['xmlAgg'], options?: AggregateOptions<T, As>): SelectAgg<T, 'xmlagg', As, NullableColumn<StringColumn>>;
|
|
332
|
+
_selectXmlAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Aggregate1ArgumentTypes<T>['xmlAgg'], options?: AggregateOptions<T, As>): SelectAgg<T, 'xmlagg', As, NullableColumn<StringColumn>>;
|
|
333
|
+
jsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
334
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
335
|
+
}>>>;
|
|
336
|
+
_jsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
337
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
338
|
+
}>>>;
|
|
339
|
+
selectJsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_object_agg', As, NullableColumn<ColumnType<{
|
|
340
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
341
|
+
}>>>;
|
|
342
|
+
_selectJsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_object_agg', As, NullableColumn<ColumnType<{
|
|
343
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
344
|
+
}>>>;
|
|
345
|
+
jsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
346
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
347
|
+
}>>>;
|
|
348
|
+
_jsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
349
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
350
|
+
}>>>;
|
|
351
|
+
selectJsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_object_agg', As, NullableColumn<ColumnType<{
|
|
352
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
353
|
+
}>>>;
|
|
354
|
+
_selectJsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_object_agg', As, NullableColumn<ColumnType<{
|
|
355
|
+
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
356
|
+
}>>>;
|
|
357
|
+
stringAgg<T extends Query>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
358
|
+
_stringAgg<T extends Query>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
359
|
+
selectStringAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T, As>): SelectAgg<T, 'string_agg', As, NullableColumn<StringColumn>>;
|
|
360
|
+
_selectStringAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T, As>): SelectAgg<T, 'string_agg', As, NullableColumn<StringColumn>>;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
declare type BeforeCallback<T extends Query> = (query: T) => void | Promise<void>;
|
|
364
|
+
declare type AfterCallback<T extends Query> = (query: T, data: unknown) => void | Promise<void>;
|
|
365
|
+
declare class QueryCallbacks {
|
|
366
|
+
beforeQuery<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
367
|
+
_beforeQuery<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
368
|
+
afterQuery<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
369
|
+
_afterQuery<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
370
|
+
beforeInsert<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
371
|
+
_beforeInsert<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
372
|
+
afterInsert<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
373
|
+
_afterInsert<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
374
|
+
beforeUpdate<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
375
|
+
_beforeUpdate<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
376
|
+
afterUpdate<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
377
|
+
_afterUpdate<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
declare type ClearStatement = 'with' | 'select' | 'where' | 'union' | 'using' | 'join' | 'group' | 'order' | 'having' | 'limit' | 'offset' | 'counters';
|
|
381
|
+
declare class Clear {
|
|
382
|
+
clear<T extends Query>(this: T, ...clears: ClearStatement[]): T;
|
|
383
|
+
_clear<T extends Query>(this: T, ...clears: ClearStatement[]): T;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare type ColumnInfo = {
|
|
387
|
+
defaultValue: unknown;
|
|
388
|
+
type: string;
|
|
389
|
+
maxLength: number | null;
|
|
390
|
+
nullable: boolean;
|
|
391
|
+
};
|
|
392
|
+
declare class ColumnInfoMethods {
|
|
393
|
+
columnInfo<T extends Query, Column extends keyof T['shape'] | undefined = undefined>(this: T, column?: Column): SetQueryReturnsColumnInfo<T, Column>;
|
|
394
|
+
_columnInfo<T extends Query, Column extends keyof T['shape'] | undefined = undefined>(this: T, column?: Column): SetQueryReturnsColumnInfo<T, Column>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
declare type DeleteArgs<T extends Query> = T['hasWhere'] extends true ? [forceAll?: boolean] : [true];
|
|
398
|
+
declare type DeleteResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T;
|
|
399
|
+
declare class Delete {
|
|
400
|
+
del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
401
|
+
_del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
402
|
+
delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
403
|
+
_delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
declare type ForQueryBuilder<Q extends Query> = Q & {
|
|
407
|
+
noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
408
|
+
_noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
409
|
+
skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
410
|
+
_skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
411
|
+
};
|
|
412
|
+
declare class For {
|
|
413
|
+
forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
414
|
+
_forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
415
|
+
forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
416
|
+
_forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
417
|
+
forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
418
|
+
_forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
419
|
+
forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
420
|
+
_forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
declare type FromArgs<T extends Query> = [
|
|
424
|
+
first: string | Query | RawExpression | Exclude<keyof T['withData'], symbol | number>,
|
|
425
|
+
second?: string | {
|
|
426
|
+
as?: string;
|
|
427
|
+
only?: boolean;
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
declare type FromResult<T extends Query, Args extends FromArgs<T>> = Args[1] extends string ? SetQueryTableAlias<T, Args[1]> : Args[1] extends {
|
|
431
|
+
as: string;
|
|
432
|
+
} ? SetQueryTableAlias<T, Args[1]['as']> : Args[0] extends string ? SetQueryTableAlias<T, Args[0]> : Args[0] extends Query ? SetQueryTableAlias<T, AliasOrTable<Args[0]>> : T;
|
|
433
|
+
declare class From {
|
|
434
|
+
from<T extends Query, Args extends FromArgs<T>>(this: T, ...args: Args): FromResult<T, Args>;
|
|
435
|
+
_from<T extends Query, Args extends FromArgs<T>>(this: T, ...args: Args): FromResult<T, Args>;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
declare type GetArg<T extends QueryBase> = StringKey<keyof T['selectable']> | RawExpression;
|
|
439
|
+
declare type UnwrapRaw<T extends Query, Arg extends GetArg<T>> = Arg extends RawExpression ? Arg['__column'] : Exclude<Arg, RawExpression>;
|
|
440
|
+
declare type GetResult<T extends Query, Arg extends GetArg<T>> = SetQueryReturnsValue<T, UnwrapRaw<T, Arg>>;
|
|
441
|
+
declare type GetOptionalResult<T extends Query, Arg extends GetArg<T>> = SetQueryReturnsValueOptional<T, UnwrapRaw<T, Arg>>;
|
|
442
|
+
declare type getValueKey = typeof getValueKey;
|
|
443
|
+
declare const getValueKey: unique symbol;
|
|
444
|
+
declare class QueryGet {
|
|
445
|
+
get<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetResult<T, Arg>;
|
|
446
|
+
_get<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetResult<T, Arg>;
|
|
447
|
+
getOptional<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetOptionalResult<T, Arg>;
|
|
448
|
+
_getOptional<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetOptionalResult<T, Arg>;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
declare type HavingArgObject<T extends Query, Agg extends keyof Aggregate1ArgumentTypes<T>> = {
|
|
452
|
+
[Column in Exclude<Aggregate1ArgumentTypes<T>[Agg], RawExpression>]?: T['selectable'][Column]['column']['type'] | (ColumnOperators<T['selectable'], Column> & AggregateOptions<T>);
|
|
453
|
+
};
|
|
454
|
+
declare type HavingArg<T extends Query = Query> = ({
|
|
455
|
+
[Agg in keyof Aggregate1ArgumentTypes<T>]?: HavingArgObject<T, Agg>;
|
|
456
|
+
} & {
|
|
457
|
+
count?: number | HavingArgObject<T, 'count'>;
|
|
458
|
+
}) | Query | RawExpression;
|
|
459
|
+
declare class Having {
|
|
460
|
+
having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
461
|
+
_having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
462
|
+
havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
463
|
+
_havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
declare type InsertData<T extends Query, DefaultKeys extends PropertyKey = keyof T[defaultsKey], Data = SetOptional<T['inputType'], DefaultKeys>> = [keyof T['relations']] extends [never] ? Data : OmitBelongsToForeignKeys<T['relations'], Data> & InsertRelationData<T>;
|
|
467
|
+
declare type OmitBelongsToForeignKeys<R extends RelationsBase, Data> = Omit<Data, {
|
|
468
|
+
[K in keyof R]: R[K] extends BelongsToRelation ? R[K]['options']['foreignKey'] : never;
|
|
469
|
+
}[keyof R]>;
|
|
470
|
+
declare type InsertRelationData<T extends Query> = {
|
|
471
|
+
[Key in keyof T['relations']]: T['relations'][Key] extends BelongsToRelation ? InsertBelongsToData<T, Key, T['relations'][Key]> : T['relations'][Key] extends HasOneRelation ? InsertHasOneData<T, Key, T['relations'][Key]> : T['relations'][Key] extends HasManyRelation | HasAndBelongsToManyRelation ? InsertHasManyData<T, Key, T['relations'][Key]> : {};
|
|
261
472
|
}[keyof T['relations']];
|
|
473
|
+
declare type InsertBelongsToData<T extends Query, Key extends keyof T['relations'], Rel extends BelongsToRelation> = SetOptional<{
|
|
474
|
+
[K in Rel['options']['foreignKey']]: Rel['options']['foreignKey'] extends keyof T['inputType'] ? T['inputType'][Rel['options']['foreignKey']] : never;
|
|
475
|
+
}, keyof T[defaultsKey]> | {
|
|
476
|
+
[K in Key]: {
|
|
477
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
478
|
+
connect?: never;
|
|
479
|
+
connectOrCreate?: never;
|
|
480
|
+
} | {
|
|
481
|
+
create?: never;
|
|
482
|
+
connect: WhereArg<Rel['model']>;
|
|
483
|
+
connectOrCreate?: never;
|
|
484
|
+
} | {
|
|
485
|
+
create?: never;
|
|
486
|
+
connect?: never;
|
|
487
|
+
connectOrCreate: {
|
|
488
|
+
where: WhereArg<Rel['model']>;
|
|
489
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
declare type InsertHasOneData<T extends Query, Key extends keyof T['relations'], Rel extends HasOneRelation> = 'through' extends Rel['options'] ? {} : {
|
|
494
|
+
[K in Key]?: {
|
|
495
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
496
|
+
connect?: never;
|
|
497
|
+
connectOrCreate?: never;
|
|
498
|
+
} | {
|
|
499
|
+
create?: never;
|
|
500
|
+
connect: WhereArg<Rel['model']>;
|
|
501
|
+
connectOrCreate?: never;
|
|
502
|
+
} | {
|
|
503
|
+
create?: never;
|
|
504
|
+
connect?: never;
|
|
505
|
+
connectOrCreate: {
|
|
506
|
+
where?: WhereArg<Rel['model']>;
|
|
507
|
+
create?: InsertData<Rel['nestedCreateQuery']>;
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
declare type InsertHasManyData<T extends Query, Key extends keyof T['relations'], Rel extends HasManyRelation | HasAndBelongsToManyRelation> = 'through' extends Rel['options'] ? {} : {
|
|
512
|
+
[K in Key]?: {
|
|
513
|
+
create?: InsertData<Rel['nestedCreateQuery']>[];
|
|
514
|
+
connect?: WhereArg<Rel['model']>[];
|
|
515
|
+
connectOrCreate?: {
|
|
516
|
+
where: WhereArg<Rel['model']>;
|
|
517
|
+
create: InsertData<Rel['nestedCreateQuery']>;
|
|
518
|
+
}[];
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
declare type InsertRawData = {
|
|
522
|
+
columns: string[];
|
|
523
|
+
values: RawExpression;
|
|
524
|
+
};
|
|
262
525
|
declare type InsertOneResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T['returnType'] extends 'all' ? SetQueryReturnsOne<T> : T['returnType'] extends 'one' ? SetQueryReturnsOne<T> : T;
|
|
263
526
|
declare type InsertManyResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAll<T> : T;
|
|
264
527
|
declare type OnConflictArg<T extends Query> = keyof T['shape'] | (keyof T['shape'])[] | RawExpression;
|
|
265
528
|
declare class Insert {
|
|
266
529
|
insert<T extends Query>(this: T, data: InsertData<T>): InsertOneResult<T>;
|
|
267
|
-
insert<T extends Query>(this: T, data: InsertData<T>[] | {
|
|
268
|
-
columns: string[];
|
|
269
|
-
values: RawExpression;
|
|
270
|
-
}): InsertManyResult<T>;
|
|
271
530
|
_insert<T extends Query>(this: T, data: InsertData<T>): InsertOneResult<T>;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
531
|
+
insertMany<T extends Query>(this: T, data: InsertData<T>[]): InsertManyResult<T>;
|
|
532
|
+
_insertMany<T extends Query>(this: T, data: InsertData<T>[]): InsertManyResult<T>;
|
|
533
|
+
insertRaw<T extends Query>(this: T, data: InsertRawData): InsertManyResult<T>;
|
|
534
|
+
_insertRaw<T extends Query>(this: T, data: InsertRawData): InsertManyResult<T>;
|
|
276
535
|
create<T extends Query>(this: T, data: InsertData<T>): SetQueryReturnsOne<T>;
|
|
277
|
-
create<T extends Query>(this: T, data: InsertData<T>[] | {
|
|
278
|
-
columns: string[];
|
|
279
|
-
values: RawExpression;
|
|
280
|
-
}): SetQueryReturnsAll<T>;
|
|
281
536
|
_create<T extends Query>(this: T, data: InsertData<T>): SetQueryReturnsOne<T>;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
537
|
+
createMany<T extends Query>(this: T, data: InsertData<T>[]): SetQueryReturnsAll<T>;
|
|
538
|
+
_createMany<T extends Query>(this: T, data: InsertData<T>[]): SetQueryReturnsAll<T>;
|
|
539
|
+
createRaw<T extends Query>(this: T, data: InsertRawData): SetQueryReturnsAll<T>;
|
|
540
|
+
_createRaw<T extends Query>(this: T, data: InsertRawData): SetQueryReturnsAll<T>;
|
|
286
541
|
defaults<T extends Query, Data extends Partial<InsertData<T>>>(this: T, data: Data): T & {
|
|
287
542
|
[defaultsKey]: Record<keyof Data, true>;
|
|
288
543
|
};
|
|
@@ -300,11 +555,192 @@ declare class OnConflictQueryBuilder<T extends Query, Arg extends OnConflictArg<
|
|
|
300
555
|
merge(update?: keyof T['shape'] | (keyof T['shape'])[] | Partial<T['inputType']> | RawExpression): T;
|
|
301
556
|
}
|
|
302
557
|
|
|
303
|
-
declare type
|
|
304
|
-
[K in keyof T['
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
558
|
+
declare type JsonColumnName<T extends Pick<Query, 'selectable'>> = StringKey<{
|
|
559
|
+
[K in keyof T['selectable']]: T['selectable'][K]['column']['dataType'] extends 'jsonb' ? K : never;
|
|
560
|
+
}[keyof T['selectable']]>;
|
|
561
|
+
declare type ColumnOrJsonMethod<T extends Query> = JsonColumnName<T> | JsonItem;
|
|
562
|
+
declare type JsonSetResult<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string, Type extends ColumnType = Column extends keyof T['shape'] ? T['shape'][Column] : Column extends JsonItem ? Column['__json'][2] : ColumnType> = JsonItem<As, Type> & (Type extends ColumnType ? AddQuerySelect<T, Record<As, Type>> : T);
|
|
563
|
+
declare type JsonPathQueryResult<T extends Query, As extends string, Type extends ColumnType> = JsonItem & AddQuerySelect<T, {
|
|
564
|
+
[K in As]: Type;
|
|
565
|
+
}>;
|
|
566
|
+
declare class Json {
|
|
567
|
+
json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
568
|
+
_json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
569
|
+
jsonSet<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
570
|
+
as?: As;
|
|
571
|
+
createIfMissing?: boolean;
|
|
572
|
+
}): JsonSetResult<T, Column, As>;
|
|
573
|
+
_jsonSet<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
574
|
+
as?: As;
|
|
575
|
+
createIfMissing?: boolean;
|
|
576
|
+
}): JsonSetResult<T, Column, As>;
|
|
577
|
+
jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
578
|
+
column: Column,
|
|
579
|
+
path: Array<string | number>,
|
|
580
|
+
value: unknown,
|
|
581
|
+
options?: {
|
|
582
|
+
as?: As;
|
|
583
|
+
insertAfter?: boolean;
|
|
584
|
+
}
|
|
585
|
+
]): JsonSetResult<T, Column, As>;
|
|
586
|
+
_jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
587
|
+
as?: As;
|
|
588
|
+
insertAfter?: boolean;
|
|
589
|
+
}): JsonSetResult<T, Column, As>;
|
|
590
|
+
jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
591
|
+
column: Column,
|
|
592
|
+
path: Array<string | number>,
|
|
593
|
+
options?: {
|
|
594
|
+
as?: As;
|
|
595
|
+
}
|
|
596
|
+
]): JsonSetResult<T, Column, As>;
|
|
597
|
+
_jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, options?: {
|
|
598
|
+
as?: As;
|
|
599
|
+
}): JsonSetResult<T, Column, As>;
|
|
600
|
+
jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, ...args: [
|
|
601
|
+
type: Type,
|
|
602
|
+
column: ColumnOrJsonMethod<T>,
|
|
603
|
+
path: string,
|
|
604
|
+
as: As,
|
|
605
|
+
options?: {
|
|
606
|
+
vars?: string;
|
|
607
|
+
silent?: boolean;
|
|
608
|
+
}
|
|
609
|
+
]): JsonPathQueryResult<T, As, Type>;
|
|
610
|
+
_jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, type: Type, column: ColumnOrJsonMethod<T>, path: string, as: As, options?: {
|
|
611
|
+
vars?: string;
|
|
612
|
+
silent?: boolean;
|
|
613
|
+
}): JsonPathQueryResult<T, As, Type>;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
declare type QueryLogObject = {
|
|
617
|
+
colors: boolean;
|
|
618
|
+
beforeQuery(sql: Sql): unknown;
|
|
619
|
+
afterQuery(sql: Sql, logData: unknown): void;
|
|
620
|
+
onError(error: Error, sql: Sql, logData: unknown): void;
|
|
621
|
+
};
|
|
622
|
+
declare type QueryLogger = {
|
|
623
|
+
log(message: string): void;
|
|
624
|
+
error(message: string): void;
|
|
625
|
+
};
|
|
626
|
+
declare type QueryLogOptions = {
|
|
627
|
+
log?: boolean | Partial<QueryLogObject>;
|
|
628
|
+
logger?: QueryLogger;
|
|
629
|
+
};
|
|
630
|
+
declare const logColors: {
|
|
631
|
+
boldCyanBright: (message: string) => string;
|
|
632
|
+
boldBlue: (message: string) => string;
|
|
633
|
+
boldYellow: (message: string) => string;
|
|
634
|
+
boldMagenta: (message: string) => string;
|
|
635
|
+
boldRed: (message: string) => string;
|
|
636
|
+
};
|
|
637
|
+
declare const logParamToLogObject: (logger: QueryLogger, log: QueryLogOptions['log']) => QueryLogObject | undefined;
|
|
638
|
+
declare class QueryLog {
|
|
639
|
+
log<T extends Query>(this: T, log?: boolean): T;
|
|
640
|
+
_log<T extends Query>(this: T, log?: boolean): T;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
declare type SelectArg<T extends QueryBase> = StringKey<keyof T['selectable']> | (T['relations'] extends Record<string, Relation> ? StringKey<keyof T['relations']> : never) | SelectAsArg<T>;
|
|
644
|
+
declare type SelectAsArg<T extends QueryBase> = Record<string, StringKey<keyof T['selectable']> | RawExpression | ((q: T) => Query)>;
|
|
645
|
+
declare type SelectResult<T extends Query, Args extends SelectArg<T>[], SelectAsArgs = SimpleSpread<FilterTuple<Args, SelectAsArg<T>>>> = AddQuerySelect<T, {
|
|
646
|
+
[Arg in Args[number] as Arg extends keyof T['selectable'] ? T['selectable'][Arg]['as'] : Arg extends keyof T['relations'] ? Arg : never]: Arg extends keyof T['selectable'] ? T['selectable'][Arg]['column'] : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['returns'] extends 'many' ? ArrayOfColumnsObjects<T['relations'][Arg]['model']['result']> : T['relations'][Arg]['options']['required'] extends true ? ColumnsObject<T['relations'][Arg]['model']['result']> : NullableColumn<ColumnsObject<T['relations'][Arg]['model']['result']>> : never : never;
|
|
647
|
+
} & {
|
|
648
|
+
[K in keyof SelectAsArgs]: SelectAsArgs[K] extends keyof T['selectable'] ? T['selectable'][SelectAsArgs[K]]['column'] : SelectAsArgs[K] extends RawExpression ? SelectAsArgs[K]['__column'] : SelectAsArgs[K] extends (q: T) => Query ? SelectSubQueryResult<ReturnType<SelectAsArgs[K]>> : never;
|
|
649
|
+
}>;
|
|
650
|
+
declare type SelectSubQueryResult<Arg extends Query & {
|
|
651
|
+
[isRequiredRelationKey]?: boolean;
|
|
652
|
+
}> = Arg['returnType'] extends 'all' ? ArrayOfColumnsObjects<Arg['result']> : Arg['returnType'] extends 'valueOrThrow' ? Arg['result']['value'] : Arg['returnType'] extends 'pluck' ? PluckResultColumnType<Arg['result']['pluck']> : Arg[isRequiredRelationKey] extends true ? ColumnsObject<Arg['result']> : NullableColumn<ColumnsObject<Arg['result']>>;
|
|
653
|
+
declare const addParserForRawExpression: (q: Query, key: string | getValueKey, raw: RawExpression) => void;
|
|
654
|
+
declare const addParserForSelectItem: <T extends Query>(q: T, as: string | getValueKey | undefined, key: string, arg: RawExpression<ColumnType<unknown, Operators, unknown>> | Exclude<keyof T["selectable"], number | symbol> | ((q: T) => Query)) => string | RawExpression | Query;
|
|
655
|
+
declare const addParserToQuery: (query: QueryData, key: string | getValueKey, parser: ColumnParser) => void;
|
|
656
|
+
declare const processSelectArg: <T extends Query>(q: T, as: string | undefined, arg: SelectArg<T>, columnAs?: string | getValueKey) => SelectItem;
|
|
657
|
+
declare class Select {
|
|
658
|
+
select<T extends Query, K extends SelectArg<T>[]>(this: T, ...args: K): SelectResult<T, K>;
|
|
659
|
+
_select<T extends Query, K extends SelectArg<T>[]>(this: T, ...args: K): SelectResult<T, K>;
|
|
660
|
+
selectAll<T extends Query>(this: T): QuerySelectAll<T>;
|
|
661
|
+
_selectAll<T extends Query>(this: T): QuerySelectAll<T>;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
interface QueryResultRow {
|
|
665
|
+
[column: string]: any;
|
|
666
|
+
}
|
|
667
|
+
declare type TypeParsers = Record<number, (input: string) => unknown>;
|
|
668
|
+
declare type QueryInput = string | {
|
|
669
|
+
text: string;
|
|
670
|
+
values?: unknown[];
|
|
671
|
+
};
|
|
672
|
+
declare type QueryResult<T extends QueryResultRow = any> = {
|
|
673
|
+
rowCount: number;
|
|
674
|
+
rows: T[];
|
|
675
|
+
};
|
|
676
|
+
declare type QueryArraysResult<R extends any[] = any[]> = {
|
|
677
|
+
rowCount: number;
|
|
678
|
+
rows: R[];
|
|
679
|
+
fields: {
|
|
680
|
+
name: string;
|
|
681
|
+
}[];
|
|
682
|
+
};
|
|
683
|
+
declare type AdapterOptions = Omit<PoolConfig, 'types'> & {
|
|
684
|
+
types?: TypeParsers;
|
|
685
|
+
};
|
|
686
|
+
declare class Adapter {
|
|
687
|
+
types: TypeParsers;
|
|
688
|
+
pool: Pool;
|
|
689
|
+
constructor({ types, ...config }: AdapterOptions);
|
|
690
|
+
query<T extends QueryResultRow = any>(query: QueryInput, types?: TypeParsers): Promise<QueryResult<T>>;
|
|
691
|
+
arrays<R extends any[] = any[]>(query: QueryInput, types?: TypeParsers): Promise<QueryArraysResult<R>>;
|
|
692
|
+
transaction<Result>(cb: (adapter: TransactionAdapter) => Promise<Result>): Promise<Result>;
|
|
693
|
+
destroy(): Promise<void>;
|
|
694
|
+
}
|
|
695
|
+
declare class TransactionAdapter implements Adapter {
|
|
696
|
+
pool: Pool;
|
|
697
|
+
client: PoolClient;
|
|
698
|
+
types: TypeParsers;
|
|
699
|
+
constructor(pool: Pool, client: PoolClient, types: TypeParsers);
|
|
700
|
+
query<T extends QueryResultRow = any>(query: QueryInput, types?: TypeParsers): Promise<QueryResult<T>>;
|
|
701
|
+
arrays<R extends any[] = any[]>(query: QueryInput, types?: TypeParsers): Promise<QueryArraysResult<R>>;
|
|
702
|
+
transaction<Result>(cb: (adapter: TransactionAdapter) => Promise<Result>): Promise<Result>;
|
|
703
|
+
destroy(): Promise<void>;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
declare type ThenResult<Res> = (resolve?: (value: Res) => any, reject?: (error: any) => any) => Promise<Res | never>;
|
|
707
|
+
declare const queryMethodByReturnType: Record<QueryReturnType, 'query' | 'arrays'>;
|
|
708
|
+
declare class Then {
|
|
709
|
+
then(this: Query, resolve?: (result: any) => any, reject?: (error: any) => any): Promise<any>;
|
|
710
|
+
}
|
|
711
|
+
declare const handleResult: CommonQueryData['handleResult'];
|
|
712
|
+
declare const parseResult: (q: Query, returnType: QueryReturnType, result: QueryResult) => unknown;
|
|
713
|
+
declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
|
|
714
|
+
|
|
715
|
+
declare class Transaction {
|
|
716
|
+
transaction<T extends Query, Result>(this: T, cb: (query: T) => Promise<Result>): Promise<Result>;
|
|
717
|
+
transacting<T extends Query>(this: T, query: Query): T;
|
|
718
|
+
_transacting<T extends Query>(this: T, query: Query): T;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
declare type UnionArg<T extends Query> = (Omit<Query, 'result'> & {
|
|
722
|
+
result: T['result'];
|
|
723
|
+
}) | RawExpression;
|
|
724
|
+
declare class Union {
|
|
725
|
+
union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
726
|
+
_union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
727
|
+
unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
728
|
+
_unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
729
|
+
intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
730
|
+
_intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
731
|
+
intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
732
|
+
_intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
733
|
+
except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
734
|
+
_except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
735
|
+
exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
736
|
+
_exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
declare type UpdateData<T extends Query> = {
|
|
740
|
+
[K in keyof T['type']]?: T['type'][K] | RawExpression;
|
|
741
|
+
} & (T['relations'] extends Record<string, Relation> ? {
|
|
742
|
+
[K in keyof T['relations']]?: T['relations'][K]['type'] extends 'belongsTo' ? {
|
|
743
|
+
disconnect: boolean;
|
|
308
744
|
} | {
|
|
309
745
|
set: WhereArg<T['relations'][K]['model']>;
|
|
310
746
|
} | {
|
|
@@ -375,72 +811,265 @@ declare class Update {
|
|
|
375
811
|
_decrement<T extends Query>(this: T, data: ChangeCountArg<T>): UpdateResult<T>;
|
|
376
812
|
}
|
|
377
813
|
|
|
378
|
-
declare type
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
};
|
|
382
|
-
declare type NestedInsertManyItems = {
|
|
383
|
-
create?: Record<string, unknown>[];
|
|
384
|
-
connect?: WhereArg<QueryBase>[];
|
|
385
|
-
connectOrCreate?: {
|
|
386
|
-
where: WhereArg<QueryBase>;
|
|
387
|
-
create: Record<string, unknown>;
|
|
388
|
-
}[];
|
|
389
|
-
};
|
|
390
|
-
declare type NestedInsertItem = NestedInsertOneItem | NestedInsertManyItems;
|
|
391
|
-
declare type BelongsToNestedInsert = (query: Query, relationData: NestedInsertOneItem[]) => Promise<Record<string, unknown>[]>;
|
|
392
|
-
declare type HasOneNestedInsert = (query: Query, data: [
|
|
393
|
-
selfData: Record<string, unknown>,
|
|
394
|
-
relationData: NestedInsertOneItem
|
|
395
|
-
][]) => Promise<void>;
|
|
396
|
-
declare type HasManyNestedInsert = (query: Query, data: [
|
|
397
|
-
selfData: Record<string, unknown>,
|
|
398
|
-
relationData: NestedInsertManyItems
|
|
399
|
-
][]) => Promise<void>;
|
|
400
|
-
declare type NestedUpdateOneItem = {
|
|
401
|
-
disconnect?: boolean;
|
|
402
|
-
set?: WhereArg<QueryBase>;
|
|
403
|
-
delete?: boolean;
|
|
404
|
-
update?: UpdateData<Query>;
|
|
405
|
-
upsert?: {
|
|
406
|
-
update: UpdateData<Query>;
|
|
407
|
-
create: Record<string, unknown>;
|
|
408
|
-
};
|
|
409
|
-
create: Record<string, unknown>;
|
|
410
|
-
};
|
|
411
|
-
declare type NestedUpdateManyItems = {
|
|
412
|
-
disconnect?: MaybeArray<WhereArg<QueryBase>>;
|
|
413
|
-
set?: MaybeArray<WhereArg<QueryBase>>;
|
|
414
|
-
delete?: MaybeArray<WhereArg<QueryBase>>;
|
|
415
|
-
update?: {
|
|
416
|
-
where: MaybeArray<WhereArg<QueryBase>>;
|
|
417
|
-
data: UpdateData<Query>;
|
|
418
|
-
};
|
|
419
|
-
create: Record<string, unknown>[];
|
|
814
|
+
declare type UpsertData<T extends Query> = {
|
|
815
|
+
update: UpdateData<T>;
|
|
816
|
+
create: InsertData<T>;
|
|
420
817
|
};
|
|
421
|
-
declare type
|
|
422
|
-
declare type
|
|
423
|
-
|
|
424
|
-
updateLaterPromises?: Promise<void>[];
|
|
425
|
-
}) => boolean;
|
|
426
|
-
declare type HasOneNestedUpdate = (query: Query, data: Record<string, unknown>[], relationData: NestedUpdateOneItem) => Promise<void>;
|
|
427
|
-
declare type HasManyNestedUpdate = (query: Query, data: Record<string, unknown>[], relationData: NestedUpdateManyItems) => Promise<void>;
|
|
428
|
-
declare type BaseRelation = {
|
|
429
|
-
type: string;
|
|
430
|
-
key: string;
|
|
431
|
-
model: QueryWithTable;
|
|
432
|
-
query: QueryWithTable;
|
|
433
|
-
joinQuery(fromQuery: QueryBase, toQuery: Query): Query;
|
|
434
|
-
nestedCreateQuery: Query;
|
|
435
|
-
nestedInsert?: BelongsToNestedInsert | HasOneNestedInsert | HasManyNestedInsert;
|
|
436
|
-
nestedUpdate?: BelongsToNestedUpdate | HasOneNestedUpdate | HasManyNestedUpdate;
|
|
437
|
-
primaryKey: string;
|
|
438
|
-
options: {
|
|
439
|
-
scope?(q: QueryWithTable): QueryWithTable;
|
|
440
|
-
required?: boolean;
|
|
441
|
-
};
|
|
818
|
+
declare type UpsertResult<T extends Query> = T['hasSelect'] extends true ? SetQueryReturnsOne<T> : SetQueryReturnsVoid<T>;
|
|
819
|
+
declare type UpsertThis = WhereResult<Query> & {
|
|
820
|
+
returnType: 'one' | 'oneOrThrow';
|
|
442
821
|
};
|
|
443
|
-
|
|
822
|
+
declare class QueryUpsert {
|
|
823
|
+
upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
824
|
+
_upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
declare type DbTableOptions = {
|
|
828
|
+
schema?: string;
|
|
829
|
+
} & QueryLogOptions;
|
|
830
|
+
interface Db<Table extends string | undefined = undefined, Shape extends ColumnsShape = Record<string, never>, Relations extends Query['relations'] = Query['relations']> extends QueryMethods {
|
|
831
|
+
new (adapter: Adapter, queryBuilder: Db, table?: Table, shape?: Shape, options?: DbTableOptions): this;
|
|
832
|
+
adapter: Adapter;
|
|
833
|
+
queryBuilder: Db;
|
|
834
|
+
whereQueryBuilder: Query['whereQueryBuilder'];
|
|
835
|
+
table: Table;
|
|
836
|
+
shape: Shape;
|
|
837
|
+
schema: TableSchema<Shape>;
|
|
838
|
+
type: ColumnShapeOutput<Shape>;
|
|
839
|
+
inputType: ColumnShapeInput<Shape>;
|
|
840
|
+
returnType: 'all';
|
|
841
|
+
then: ThenResult<Pick<ColumnShapeOutput<Shape>, DefaultSelectColumns<Shape>[number]>[]>;
|
|
842
|
+
query: QueryData;
|
|
843
|
+
columns: (keyof ColumnShapeOutput<Shape>)[];
|
|
844
|
+
defaultSelectColumns: DefaultSelectColumns<Shape>;
|
|
845
|
+
columnsParsers?: ColumnsParsers;
|
|
846
|
+
result: Pick<Shape, DefaultSelectColumns<Shape>[number]>;
|
|
847
|
+
hasSelect: false;
|
|
848
|
+
hasWhere: boolean;
|
|
849
|
+
selectable: {
|
|
850
|
+
[K in keyof Shape]: {
|
|
851
|
+
as: K;
|
|
852
|
+
column: Shape[K];
|
|
853
|
+
};
|
|
854
|
+
} & {
|
|
855
|
+
[K in keyof Shape as `${Table}.${StringKey<K>}`]: {
|
|
856
|
+
as: K;
|
|
857
|
+
column: Shape[K];
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
tableAlias: undefined;
|
|
861
|
+
windows: PropertyKey[];
|
|
862
|
+
withData: Query['withData'];
|
|
863
|
+
joinedTables: Query['joinedTables'];
|
|
864
|
+
relations: Relations;
|
|
865
|
+
[defaultsKey]: Record<{
|
|
866
|
+
[K in keyof Shape]: Shape[K]['hasDefault'] extends true ? K : never;
|
|
867
|
+
}[keyof Shape], true>;
|
|
868
|
+
}
|
|
869
|
+
declare class Db<Table extends string | undefined = undefined, Shape extends ColumnsShape = Record<string, never>, Relations extends Query['relations'] = Query['relations']> implements Query {
|
|
870
|
+
adapter: Adapter;
|
|
871
|
+
queryBuilder: Db;
|
|
872
|
+
table: Table;
|
|
873
|
+
shape: Shape;
|
|
874
|
+
whereQueryBuilder: typeof WhereQueryBuilder;
|
|
875
|
+
onQueryBuilder: typeof OnQueryBuilder;
|
|
876
|
+
constructor(adapter: Adapter, queryBuilder: Db, table: Table, shape: Shape, options: DbTableOptions);
|
|
877
|
+
}
|
|
878
|
+
declare type DbResult<CT extends ColumnTypesBase> = Db & {
|
|
879
|
+
<Table extends string, Shape extends ColumnsShape = ColumnsShape>(table: Table, shape?: ((t: CT) => Shape) | Shape, options?: DbTableOptions): Db<Table, Shape>;
|
|
880
|
+
adapter: Adapter;
|
|
881
|
+
destroy: Adapter['destroy'];
|
|
882
|
+
};
|
|
883
|
+
declare type DbOptions<CT extends ColumnTypesBase = ColumnTypes> = ({
|
|
884
|
+
adapter: Adapter;
|
|
885
|
+
} | Omit<AdapterOptions, 'log'>) & QueryLogOptions & {
|
|
886
|
+
columnTypes?: CT;
|
|
887
|
+
};
|
|
888
|
+
declare const createDb: <CT extends ColumnTypesBase = {
|
|
889
|
+
smallint: () => SmallIntColumn;
|
|
890
|
+
integer: () => IntegerColumn;
|
|
891
|
+
bigint: () => BigIntColumn;
|
|
892
|
+
numeric: <Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(precision?: Precision | undefined, scale?: Scale | undefined) => DecimalColumn<Precision, Scale>;
|
|
893
|
+
decimal: <Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(precision?: Precision_1 | undefined, scale?: Scale_1 | undefined) => DecimalColumn<Precision_1, Scale_1>;
|
|
894
|
+
real: () => RealColumn;
|
|
895
|
+
doublePrecision: () => DoublePrecisionColumn;
|
|
896
|
+
smallSerial: () => SmallSerialColumn;
|
|
897
|
+
serial: () => SerialColumn;
|
|
898
|
+
bigSerial: () => BigSerialColumn;
|
|
899
|
+
money: () => MoneyColumn;
|
|
900
|
+
varchar: <Limit extends number | undefined = undefined>(limit?: Limit | undefined) => VarCharColumn<Limit>;
|
|
901
|
+
char: <Limit_1 extends number | undefined = undefined>(limit?: Limit_1 | undefined) => CharColumn<Limit_1>;
|
|
902
|
+
text: () => TextColumn;
|
|
903
|
+
string: () => TextColumn;
|
|
904
|
+
bytea: () => ByteaColumn;
|
|
905
|
+
date: () => DateColumn;
|
|
906
|
+
timestamp: <Precision_2 extends number | undefined = undefined>(precision?: Precision_2 | undefined) => TimestampColumn<Precision_2>;
|
|
907
|
+
timestampWithTimeZone: <Precision_3 extends number | undefined = undefined>(precision?: Precision_3 | undefined) => TimestampWithTimeZoneColumn<Precision_3>;
|
|
908
|
+
time: <Precision_4 extends number | undefined = undefined>(precision?: Precision_4 | undefined) => TimeColumn<Precision_4>;
|
|
909
|
+
timeWithTimeZone: <Precision_5 extends number | undefined = undefined>(precision?: Precision_5 | undefined) => TimeWithTimeZoneColumn<Precision_5>;
|
|
910
|
+
interval: <Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(fields?: Fields | undefined, precision?: Precision_6 | undefined) => IntervalColumn<Fields, Precision_6>;
|
|
911
|
+
boolean: () => BooleanColumn;
|
|
912
|
+
enum: <U extends string, T extends [U, ...U[]]>(dataType: string, type: T) => EnumColumn<U, T>;
|
|
913
|
+
point: () => PointColumn;
|
|
914
|
+
line: () => LineColumn;
|
|
915
|
+
lseg: () => LsegColumn;
|
|
916
|
+
box: () => BoxColumn;
|
|
917
|
+
path: () => PathColumn;
|
|
918
|
+
polygon: () => PolygonColumn;
|
|
919
|
+
circle: () => CircleColumn;
|
|
920
|
+
cidr: () => CidrColumn;
|
|
921
|
+
inet: () => InetColumn;
|
|
922
|
+
macaddr: () => MacAddrColumn;
|
|
923
|
+
macaddr8: () => MacAddr8Column;
|
|
924
|
+
bit: <Length extends number>(length: Length) => BitColumn<Length>;
|
|
925
|
+
bitVarying: <Length_1 extends number | undefined = undefined>(length?: Length_1 | undefined) => BitVaryingColumn<Length_1 | undefined>;
|
|
926
|
+
tsvector: () => TsVectorColumn;
|
|
927
|
+
tsquery: () => TsQueryColumn;
|
|
928
|
+
uuid: () => UUIDColumn;
|
|
929
|
+
xml: () => XMLColumn;
|
|
930
|
+
json: <Type extends JSONTypeAny>(schemaOrFn: Type | ((j: {
|
|
931
|
+
set: <Value extends JSONTypeAny>(valueType: Value) => JSONSet<Value>;
|
|
932
|
+
tuple: <T_1 extends [] | JSONTupleItems, Rest extends JSONTypeAny | null = null>(items: T_1, rest?: Rest) => JSONTuple<T_1, Rest>;
|
|
933
|
+
union: <T_2 extends [JSONTypeAny, JSONTypeAny, ...JSONTypeAny[]]>(types: T_2) => JSONUnion<T_2>;
|
|
934
|
+
any: () => JSONAny;
|
|
935
|
+
bigint: () => JSONBigInt;
|
|
936
|
+
boolean: () => JSONBoolean;
|
|
937
|
+
date: () => JSONDate;
|
|
938
|
+
nan: () => JSONNaN;
|
|
939
|
+
never: () => JSONNever;
|
|
940
|
+
null: () => JSONNull;
|
|
941
|
+
number: () => JSONNumber;
|
|
942
|
+
string: () => JSONString;
|
|
943
|
+
undefined: () => JSONUndefined;
|
|
944
|
+
unknown: () => JSONUnknown;
|
|
945
|
+
void: () => JSONVoid;
|
|
946
|
+
array: <Type_1 extends JSONTypeAny>(element: Type_1) => JSONArray<Type_1, "many">;
|
|
947
|
+
discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends Primitive, Types extends [JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
|
|
948
|
+
enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => JSONEnum<U_1, T_3>;
|
|
949
|
+
instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => JSONInstanceOf<T_4>;
|
|
950
|
+
intersection: <Left extends JSONTypeAny, Right extends JSONTypeAny>(left: Left, right: Right) => JSONIntersection<Left, Right>;
|
|
951
|
+
lazy: <T_5 extends JSONTypeAny>(fn: () => T_5) => JSONLazy<T_5>;
|
|
952
|
+
literal: <T_6 extends Primitive>(value: T_6) => JSONLiteral<T_6>;
|
|
953
|
+
map: <Key extends JSONTypeAny, Value_1 extends JSONTypeAny>(keyType: Key, valueType: Value_1) => JSONMap<Key, Value_1>;
|
|
954
|
+
nativeEnum: <T_7 extends EnumLike>(givenEnum: T_7) => JSONNativeEnum<T_7>;
|
|
955
|
+
nullable: <T_8 extends JSONTypeAny>(type: T_8) => JSONNullable<T_8>;
|
|
956
|
+
nullish: <T_9 extends JSONTypeAny>(type: T_9) => JSONNullish<T_9>;
|
|
957
|
+
object: <T_10 extends JSONObjectShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends JSONTypeAny = JSONTypeAny>(shape: T_10) => JSONObject<T_10, UnknownKeys, Catchall, JSONTypeAny extends Catchall ? addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
958
|
+
[k: string]: Catchall["type"];
|
|
959
|
+
} extends infer T_12 ? { [k_2 in keyof T_12]: ((addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
960
|
+
[k: string]: Catchall["type"];
|
|
961
|
+
})[k_2]; } : never>;
|
|
962
|
+
optional: <T_13 extends JSONTypeAny>(type: T_13) => JSONOptional<T_13>;
|
|
963
|
+
record: typeof record;
|
|
964
|
+
}) => Type)) => JSONColumn<Type>;
|
|
965
|
+
jsonText: () => JSONTextColumn;
|
|
966
|
+
array: <Item extends ColumnType<unknown, Operators, unknown>>(item: Item) => ArrayColumn<Item>;
|
|
967
|
+
timestamps<T_14 extends ColumnType<unknown, Operators, unknown>>(this: {
|
|
968
|
+
timestamp(): T_14;
|
|
969
|
+
}): {
|
|
970
|
+
createdAt: T_14 & {
|
|
971
|
+
hasDefault: true;
|
|
972
|
+
};
|
|
973
|
+
updatedAt: T_14 & {
|
|
974
|
+
hasDefault: true;
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
primaryKey(columns: string[], options?: {
|
|
978
|
+
name?: string | undefined;
|
|
979
|
+
} | undefined): {};
|
|
980
|
+
index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
|
|
981
|
+
unique(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
|
|
982
|
+
foreignKey: {
|
|
983
|
+
<Model extends ForeignKeyModelWithColumns, Columns extends [Exclude<keyof InstanceType<Model>["columns"]["shape"], number | symbol>, ...Exclude<keyof InstanceType<Model>["columns"]["shape"], number | symbol>[]]>(columns: string[], fn: () => Model, foreignColumns: Columns, options?: ForeignKeyOptions | undefined): {};
|
|
984
|
+
<Table extends string, Columns_1 extends [string, ...string[]]>(columns: string[], table: Table, foreignColumns: Columns_1, options?: ForeignKeyOptions | undefined): {};
|
|
985
|
+
};
|
|
986
|
+
}>({ log, logger, columnTypes: ct, ...options }: DbOptions<CT>) => DbResult<CT>;
|
|
987
|
+
|
|
988
|
+
declare type WithArgsOptions = Omit<WithOptions, 'columns'> & {
|
|
989
|
+
columns?: boolean | string[];
|
|
990
|
+
};
|
|
991
|
+
declare type WithArgs = [string, ColumnsShape, RawExpression] | [string, WithArgsOptions, ColumnsShape, RawExpression] | [string, Query | ((qb: Db) => Query)] | [string, WithArgsOptions, Query | ((qb: Db) => Query)];
|
|
992
|
+
declare type WithShape<Args extends WithArgs> = Args[1] extends Query ? Args[1]['result'] : Args[1] extends (qb: Db) => Query ? ReturnType<Args[1]>['result'] : Args[2] extends Query ? Args[2]['result'] : Args[2] extends (qb: Db) => Query ? ReturnType<Args[2]>['result'] : Args[1] extends ColumnsShape ? Args[1] : Args[2] extends ColumnsShape ? Args[2] : Args[2] extends (t: ColumnTypes) => ColumnsShape ? ReturnType<Args[2]> : never;
|
|
993
|
+
declare type WithResult<T extends Query, Args extends WithArgs, Shape extends ColumnsShape> = AddQueryWith<T, {
|
|
994
|
+
table: Args[0];
|
|
995
|
+
shape: Shape;
|
|
996
|
+
type: ColumnShapeOutput<Shape>;
|
|
997
|
+
}>;
|
|
998
|
+
declare class With {
|
|
999
|
+
with<T extends Query, Args extends WithArgs, Shape extends ColumnsShape = WithShape<Args>>(this: T, ...args: Args): WithResult<T, Args, Shape>;
|
|
1000
|
+
_with<T extends Query, Args extends WithArgs, Shape extends ColumnsShape = WithShape<Args>>(this: T, ...args: Args): WithResult<T, Args, Shape>;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
declare type NestedInsertOneItem = {
|
|
1004
|
+
create?: Record<string, unknown>;
|
|
1005
|
+
connect?: WhereArg<QueryBase>;
|
|
1006
|
+
connectOrCreate?: {
|
|
1007
|
+
where: WhereArg<QueryBase>;
|
|
1008
|
+
create: Record<string, unknown>;
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
declare type NestedInsertManyItems = {
|
|
1012
|
+
create?: Record<string, unknown>[];
|
|
1013
|
+
connect?: WhereArg<QueryBase>[];
|
|
1014
|
+
connectOrCreate?: {
|
|
1015
|
+
where: WhereArg<QueryBase>;
|
|
1016
|
+
create: Record<string, unknown>;
|
|
1017
|
+
}[];
|
|
1018
|
+
};
|
|
1019
|
+
declare type NestedInsertItem = NestedInsertOneItem | NestedInsertManyItems;
|
|
1020
|
+
declare type BelongsToNestedInsert = (query: Query, relationData: NestedInsertOneItem[]) => Promise<Record<string, unknown>[]>;
|
|
1021
|
+
declare type HasOneNestedInsert = (query: Query, data: [
|
|
1022
|
+
selfData: Record<string, unknown>,
|
|
1023
|
+
relationData: NestedInsertOneItem
|
|
1024
|
+
][]) => Promise<void>;
|
|
1025
|
+
declare type HasManyNestedInsert = (query: Query, data: [
|
|
1026
|
+
selfData: Record<string, unknown>,
|
|
1027
|
+
relationData: NestedInsertManyItems
|
|
1028
|
+
][]) => Promise<void>;
|
|
1029
|
+
declare type NestedUpdateOneItem = {
|
|
1030
|
+
disconnect?: boolean;
|
|
1031
|
+
set?: WhereArg<QueryBase>;
|
|
1032
|
+
delete?: boolean;
|
|
1033
|
+
update?: UpdateData<Query>;
|
|
1034
|
+
upsert?: {
|
|
1035
|
+
update: UpdateData<Query>;
|
|
1036
|
+
create: Record<string, unknown>;
|
|
1037
|
+
};
|
|
1038
|
+
create: Record<string, unknown>;
|
|
1039
|
+
};
|
|
1040
|
+
declare type NestedUpdateManyItems = {
|
|
1041
|
+
disconnect?: MaybeArray<WhereArg<QueryBase>>;
|
|
1042
|
+
set?: MaybeArray<WhereArg<QueryBase>>;
|
|
1043
|
+
delete?: MaybeArray<WhereArg<QueryBase>>;
|
|
1044
|
+
update?: {
|
|
1045
|
+
where: MaybeArray<WhereArg<QueryBase>>;
|
|
1046
|
+
data: UpdateData<Query>;
|
|
1047
|
+
};
|
|
1048
|
+
create: Record<string, unknown>[];
|
|
1049
|
+
};
|
|
1050
|
+
declare type NestedUpdateItem = NestedUpdateOneItem | NestedUpdateManyItems;
|
|
1051
|
+
declare type BelongsToNestedUpdate = (q: Query, update: Record<string, unknown>, params: NestedUpdateOneItem, state: {
|
|
1052
|
+
updateLater?: Record<string, unknown>;
|
|
1053
|
+
updateLaterPromises?: Promise<void>[];
|
|
1054
|
+
}) => boolean;
|
|
1055
|
+
declare type HasOneNestedUpdate = (query: Query, data: Record<string, unknown>[], relationData: NestedUpdateOneItem) => Promise<void>;
|
|
1056
|
+
declare type HasManyNestedUpdate = (query: Query, data: Record<string, unknown>[], relationData: NestedUpdateManyItems) => Promise<void>;
|
|
1057
|
+
declare type BaseRelation = {
|
|
1058
|
+
type: string;
|
|
1059
|
+
key: string;
|
|
1060
|
+
model: QueryWithTable;
|
|
1061
|
+
query: QueryWithTable;
|
|
1062
|
+
joinQuery(fromQuery: QueryBase, toQuery: Query): Query;
|
|
1063
|
+
nestedCreateQuery: Query;
|
|
1064
|
+
nestedInsert?: BelongsToNestedInsert | HasOneNestedInsert | HasManyNestedInsert;
|
|
1065
|
+
nestedUpdate?: BelongsToNestedUpdate | HasOneNestedUpdate | HasManyNestedUpdate;
|
|
1066
|
+
primaryKey: string;
|
|
1067
|
+
options: {
|
|
1068
|
+
scope?(q: QueryWithTable): QueryWithTable;
|
|
1069
|
+
required?: boolean;
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
interface BelongsToRelation extends BaseRelation {
|
|
444
1073
|
type: 'belongsTo';
|
|
445
1074
|
returns: 'one';
|
|
446
1075
|
options: BaseRelation['options'] & {
|
|
@@ -499,92 +1128,6 @@ declare type RelationQuery<RelationName extends PropertyKey = string, Params ext
|
|
|
499
1128
|
[defaultsKey]: Record<Populate, true>;
|
|
500
1129
|
}) & Q;
|
|
501
1130
|
|
|
502
|
-
interface QueryResultRow {
|
|
503
|
-
[column: string]: any;
|
|
504
|
-
}
|
|
505
|
-
declare type TypeParsers = Record<number, (input: string) => unknown>;
|
|
506
|
-
declare type QueryInput = string | {
|
|
507
|
-
text: string;
|
|
508
|
-
values?: unknown[];
|
|
509
|
-
};
|
|
510
|
-
declare type QueryResult<T extends QueryResultRow = any> = {
|
|
511
|
-
rowCount: number;
|
|
512
|
-
rows: T[];
|
|
513
|
-
};
|
|
514
|
-
declare type QueryArraysResult<R extends any[] = any[]> = {
|
|
515
|
-
rowCount: number;
|
|
516
|
-
rows: R[];
|
|
517
|
-
fields: {
|
|
518
|
-
name: string;
|
|
519
|
-
}[];
|
|
520
|
-
};
|
|
521
|
-
declare type AdapterOptions = Omit<PoolConfig, 'types'> & {
|
|
522
|
-
types?: TypeParsers;
|
|
523
|
-
};
|
|
524
|
-
declare class Adapter {
|
|
525
|
-
types: TypeParsers;
|
|
526
|
-
pool: Pool;
|
|
527
|
-
constructor({ types, ...config }: AdapterOptions);
|
|
528
|
-
query<T extends QueryResultRow = any>(query: QueryInput, types?: TypeParsers): Promise<QueryResult<T>>;
|
|
529
|
-
arrays<R extends any[] = any[]>(query: QueryInput, types?: TypeParsers): Promise<QueryArraysResult<R>>;
|
|
530
|
-
transaction<Result>(cb: (adapter: TransactionAdapter) => Promise<Result>): Promise<Result>;
|
|
531
|
-
destroy(): Promise<void>;
|
|
532
|
-
}
|
|
533
|
-
declare class TransactionAdapter implements Adapter {
|
|
534
|
-
pool: Pool;
|
|
535
|
-
client: PoolClient;
|
|
536
|
-
types: TypeParsers;
|
|
537
|
-
constructor(pool: Pool, client: PoolClient, types: TypeParsers);
|
|
538
|
-
query<T extends QueryResultRow = any>(query: QueryInput, types?: TypeParsers): Promise<QueryResult<T>>;
|
|
539
|
-
arrays<R extends any[] = any[]>(query: QueryInput, types?: TypeParsers): Promise<QueryArraysResult<R>>;
|
|
540
|
-
transaction<Result>(cb: (adapter: TransactionAdapter) => Promise<Result>): Promise<Result>;
|
|
541
|
-
destroy(): Promise<void>;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
declare type QueryLogObject = {
|
|
545
|
-
colors: boolean;
|
|
546
|
-
beforeQuery(sql: Sql): unknown;
|
|
547
|
-
afterQuery(sql: Sql, logData: unknown): void;
|
|
548
|
-
onError(error: Error, sql: Sql, logData: unknown): void;
|
|
549
|
-
};
|
|
550
|
-
declare type QueryLogger = {
|
|
551
|
-
log(message: string): void;
|
|
552
|
-
error(message: string): void;
|
|
553
|
-
};
|
|
554
|
-
declare type QueryLogOptions = {
|
|
555
|
-
log?: boolean | Partial<QueryLogObject>;
|
|
556
|
-
logger?: QueryLogger;
|
|
557
|
-
};
|
|
558
|
-
declare const logColors: {
|
|
559
|
-
boldCyanBright: (message: string) => string;
|
|
560
|
-
boldBlue: (message: string) => string;
|
|
561
|
-
boldYellow: (message: string) => string;
|
|
562
|
-
boldMagenta: (message: string) => string;
|
|
563
|
-
boldRed: (message: string) => string;
|
|
564
|
-
};
|
|
565
|
-
declare const logParamToLogObject: (logger: QueryLogger, log: QueryLogOptions['log']) => QueryLogObject | undefined;
|
|
566
|
-
declare class QueryLog {
|
|
567
|
-
log<T extends Query>(this: T, log?: boolean): T;
|
|
568
|
-
_log<T extends Query>(this: T, log?: boolean): T;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
declare type BeforeCallback<T extends Query> = (query: T) => void | Promise<void>;
|
|
572
|
-
declare type AfterCallback<T extends Query> = (query: T, data: unknown) => void | Promise<void>;
|
|
573
|
-
declare class QueryCallbacks {
|
|
574
|
-
beforeQuery<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
575
|
-
_beforeQuery<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
576
|
-
afterQuery<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
577
|
-
_afterQuery<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
578
|
-
beforeInsert<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
579
|
-
_beforeInsert<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
580
|
-
afterInsert<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
581
|
-
_afterInsert<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
582
|
-
beforeUpdate<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
583
|
-
_beforeUpdate<T extends Query>(this: T, cb: BeforeCallback<T>): T;
|
|
584
|
-
afterUpdate<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
585
|
-
_afterUpdate<T extends Query>(this: T, cb: AfterCallback<T>): T;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
1131
|
declare type Sql = {
|
|
589
1132
|
text: string;
|
|
590
1133
|
values: unknown[];
|
|
@@ -742,603 +1285,86 @@ declare type SelectFunctionItem = {
|
|
|
742
1285
|
};
|
|
743
1286
|
declare type JoinItem = {
|
|
744
1287
|
type: string;
|
|
745
|
-
args: [relation: string] | [
|
|
746
|
-
arg: string | QueryWithTable,
|
|
747
|
-
conditions: Record<string, string | RawExpression> | RawExpression | ((q: unknown) => QueryBase)
|
|
748
|
-
] | [
|
|
749
|
-
arg: string | QueryWithTable,
|
|
750
|
-
leftColumn: string | RawExpression,
|
|
751
|
-
rightColumn: string | RawExpression
|
|
752
|
-
] | [
|
|
753
|
-
arg: string | QueryWithTable,
|
|
754
|
-
leftColumn: string | RawExpression,
|
|
755
|
-
op: string,
|
|
756
|
-
rightColumn: string | RawExpression
|
|
757
|
-
];
|
|
758
|
-
};
|
|
759
|
-
declare type WhereItem = (Omit<Record<string, unknown | Record<string, unknown | Query | RawExpression> | RawExpression>, 'NOT' | 'AND' | 'OR' | 'IN' | 'EXISTS' | 'ON' | 'ON_JSON_PATH_EQUALS'> & {
|
|
760
|
-
NOT?: MaybeArray<WhereItem>;
|
|
761
|
-
AND?: MaybeArray<WhereItem>;
|
|
762
|
-
OR?: MaybeArray<WhereItem>[];
|
|
763
|
-
IN?: MaybeArray<WhereInItem>;
|
|
764
|
-
EXISTS?: MaybeArray<JoinItem['args']>;
|
|
765
|
-
ON?: WhereOnItem | WhereJsonPathEqualsItem;
|
|
766
|
-
}) | ((q: unknown) => QueryBase) | Query | RawExpression;
|
|
767
|
-
declare type WhereInItem = {
|
|
768
|
-
columns: string[];
|
|
769
|
-
values: unknown[][] | Query | RawExpression;
|
|
770
|
-
};
|
|
771
|
-
declare type WhereJsonPathEqualsItem = [
|
|
772
|
-
leftColumn: string,
|
|
773
|
-
leftPath: string,
|
|
774
|
-
rightColumn: string,
|
|
775
|
-
rightPath: string
|
|
776
|
-
];
|
|
777
|
-
declare type WhereOnItem = {
|
|
778
|
-
joinFrom: WhereOnJoinItem;
|
|
779
|
-
joinTo: WhereOnJoinItem;
|
|
780
|
-
on: [leftFullColumn: string, rightFullColumn: string] | [leftFullColumn: string, op: string, rightFullColumn: string];
|
|
781
|
-
};
|
|
782
|
-
declare type WhereOnJoinItem = {
|
|
783
|
-
table?: string;
|
|
784
|
-
query: {
|
|
785
|
-
as?: string;
|
|
786
|
-
};
|
|
787
|
-
} | string;
|
|
788
|
-
declare type AggregateItemOptions = {
|
|
789
|
-
as?: string;
|
|
790
|
-
distinct?: boolean;
|
|
791
|
-
order?: OrderItem[];
|
|
792
|
-
filter?: WhereItem;
|
|
793
|
-
filterOr?: WhereItem[];
|
|
794
|
-
withinGroup?: boolean;
|
|
795
|
-
over?: string;
|
|
796
|
-
window?: WindowItem;
|
|
797
|
-
};
|
|
798
|
-
declare type SortDir = 'ASC' | 'DESC';
|
|
799
|
-
declare type OrderItem = string | Record<string, SortDir | {
|
|
800
|
-
dir: SortDir;
|
|
801
|
-
nulls: 'FIRST' | 'LAST';
|
|
802
|
-
}> | RawExpression;
|
|
803
|
-
declare type AggregateItemArg = Expression | Record<string, Expression> | [Expression, string];
|
|
804
|
-
declare type AggregateItem = {
|
|
805
|
-
function: string;
|
|
806
|
-
arg?: AggregateItemArg;
|
|
807
|
-
options: AggregateItemOptions;
|
|
808
|
-
};
|
|
809
|
-
declare type ColumnOperators<S extends SelectableBase, Column extends keyof S> = {
|
|
810
|
-
[O in keyof S[Column]['column']['operators']]?: S[Column]['column']['operators'][O]['type'];
|
|
811
|
-
};
|
|
812
|
-
declare type HavingItemObject = Record<string, unknown>;
|
|
813
|
-
declare type HavingItem = Record<string, HavingItemObject> | {
|
|
814
|
-
count?: number | HavingItemObject;
|
|
815
|
-
} | Query | RawExpression;
|
|
816
|
-
declare type WindowItem = Record<string, WindowDeclaration | RawExpression>;
|
|
817
|
-
declare type WindowDeclaration = {
|
|
818
|
-
partitionBy?: Expression | Expression[];
|
|
819
|
-
order?: OrderItem;
|
|
820
|
-
};
|
|
821
|
-
declare type UnionItem = Query | RawExpression;
|
|
822
|
-
declare type UnionKind = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' | 'EXCEPT' | 'EXCEPT ALL';
|
|
823
|
-
declare type OnConflictItem = string | string[] | RawExpression;
|
|
824
|
-
declare type OnConflictMergeUpdate = string | string[] | Record<string, unknown> | RawExpression;
|
|
825
|
-
|
|
826
|
-
declare type AggregateArg<T extends Query> = Expression<T> | Record<string, Expression<T>> | [Expression<T>, string];
|
|
827
|
-
declare type AggregateOptions<T extends Query = Query, As extends string | undefined = any> = {
|
|
828
|
-
as?: As;
|
|
829
|
-
distinct?: boolean;
|
|
830
|
-
order?: OrderArg<T> | OrderArg<T>[];
|
|
831
|
-
filter?: WhereArg<T>;
|
|
832
|
-
filterOr?: WhereArg<T>[];
|
|
833
|
-
withinGroup?: boolean;
|
|
834
|
-
over?: T['windows'][number] | WindowArgDeclaration<T>;
|
|
835
|
-
};
|
|
836
|
-
declare type Aggregate1ArgumentTypes<T extends Query = Query, C extends ColumnType = ColumnType> = {
|
|
837
|
-
count: Expression<T, C>;
|
|
838
|
-
avg: NumberExpression<T, C>;
|
|
839
|
-
min: Expression<T, C>;
|
|
840
|
-
max: Expression<T, C>;
|
|
841
|
-
sum: NumberExpression<T, C>;
|
|
842
|
-
bitAnd: NumberExpression<T, C>;
|
|
843
|
-
bitOr: NumberExpression<T, C>;
|
|
844
|
-
boolAnd: BooleanExpression<T, C>;
|
|
845
|
-
boolOr: BooleanExpression<T, C>;
|
|
846
|
-
every: BooleanExpression<T, C>;
|
|
847
|
-
jsonAgg: Expression<T, C>;
|
|
848
|
-
jsonbAgg: Expression<T, C>;
|
|
849
|
-
xmlAgg: Expression<T, C>;
|
|
850
|
-
};
|
|
851
|
-
declare const aggregate1FunctionNames: {
|
|
852
|
-
readonly count: "count";
|
|
853
|
-
readonly avg: "avg";
|
|
854
|
-
readonly min: "min";
|
|
855
|
-
readonly max: "max";
|
|
856
|
-
readonly sum: "sum";
|
|
857
|
-
readonly bitAnd: "bit_and";
|
|
858
|
-
readonly bitOr: "bit_or";
|
|
859
|
-
readonly boolAnd: "bool_and";
|
|
860
|
-
readonly boolOr: "bool_or";
|
|
861
|
-
readonly every: "every";
|
|
862
|
-
readonly jsonAgg: "json_agg";
|
|
863
|
-
readonly jsonbAgg: "jsonb_agg";
|
|
864
|
-
readonly xmlAgg: "xmlagg";
|
|
865
|
-
};
|
|
866
|
-
declare type SelectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType> = AddQuerySelect<T, Record<CoalesceString<As, Func>, Value>>;
|
|
867
|
-
declare type AT1<T extends Query> = Aggregate1ArgumentTypes<T>;
|
|
868
|
-
declare type WindowFunctionOptions<T extends Query = Query, As extends string | undefined = any> = {
|
|
869
|
-
as?: As;
|
|
870
|
-
} & WindowArgDeclaration<T>;
|
|
871
|
-
declare class Aggregate {
|
|
872
|
-
selectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType>(this: T, functionName: Func, arg: AggregateArg<T>, options?: AggregateOptions<T, As>): SelectAgg<T, Func, As, Value>;
|
|
873
|
-
_selectAgg<T extends Query, Func extends string, As extends string | undefined, Value extends ColumnType>(this: T, functionName: Func, arg: AggregateArg<T>, options?: AggregateOptions<T, As>, columnType?: ColumnType): SelectAgg<T, Func, As, Value>;
|
|
874
|
-
count<T extends Query>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T>): SetQueryReturnsValue<T, NumberColumn>;
|
|
875
|
-
_count<T extends Query>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T>): SetQueryReturnsValue<T, NumberColumn>;
|
|
876
|
-
selectCount<T extends Query, As extends string | undefined = undefined>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T, As>): SelectAgg<T, 'count', As, NumberColumn>;
|
|
877
|
-
_selectCount<T extends Query, As extends string | undefined = undefined>(this: T, arg?: AT1<T>['count'] | '*', options?: AggregateOptions<T, As>): SelectAgg<T, 'count', As, NumberColumn>;
|
|
878
|
-
avg<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['avg'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
879
|
-
_avg<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['avg'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
880
|
-
selectAvg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'avg', As, NullableColumn<NumberColumn>>;
|
|
881
|
-
_selectAvg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'avg', As, NullableColumn<NumberColumn>>;
|
|
882
|
-
min<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['min'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
883
|
-
_min<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['min'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
884
|
-
selectMin<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'min', As, NullableColumn<NumberColumn>>;
|
|
885
|
-
_selectMin<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'min', As, NullableColumn<NumberColumn>>;
|
|
886
|
-
max<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['max'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
887
|
-
_max<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['max'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
888
|
-
selectMax<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'max', As, NullableColumn<NumberColumn>>;
|
|
889
|
-
_selectMax<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'max', As, NullableColumn<NumberColumn>>;
|
|
890
|
-
sum<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['sum'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
891
|
-
_sum<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['sum'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
892
|
-
selectSum<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'sum', As, NullableColumn<NumberColumn>>;
|
|
893
|
-
_selectSum<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'sum', As, NullableColumn<NumberColumn>>;
|
|
894
|
-
bitAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
895
|
-
_bitAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
896
|
-
selectBitAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_and', As, NullableColumn<NumberColumn>>;
|
|
897
|
-
_selectBitAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_and', As, NullableColumn<NumberColumn>>;
|
|
898
|
-
bitOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
899
|
-
_bitOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['bitOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<NumberColumn>>;
|
|
900
|
-
selectBitOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_or', As, NullableColumn<NumberColumn>>;
|
|
901
|
-
_selectBitOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bit_or', As, NullableColumn<NumberColumn>>;
|
|
902
|
-
boolAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
903
|
-
_boolAnd<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolAnd'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
904
|
-
selectBoolAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_and', As, NullableColumn<BooleanColumn>>;
|
|
905
|
-
_selectBoolAnd<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_and', As, NullableColumn<BooleanColumn>>;
|
|
906
|
-
boolOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
907
|
-
_boolOr<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['boolOr'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
908
|
-
selectBoolOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_or', As, NullableColumn<BooleanColumn>>;
|
|
909
|
-
_selectBoolOr<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'bool_or', As, NullableColumn<BooleanColumn>>;
|
|
910
|
-
every<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['every'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
911
|
-
_every<T extends Query>(this: T, arg: Aggregate1ArgumentTypes<T>['every'], options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<BooleanColumn>>;
|
|
912
|
-
selectEvery<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'every', As, NullableColumn<BooleanColumn>>;
|
|
913
|
-
_selectEvery<T extends Query, As extends string | undefined = undefined>(this: T, arg: Expression<T>, options?: AggregateOptions<T, As>): SelectAgg<T, 'every', As, NullableColumn<BooleanColumn>>;
|
|
914
|
-
jsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
915
|
-
_jsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
916
|
-
selectJsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
917
|
-
_selectJsonAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
918
|
-
jsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
919
|
-
_jsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
920
|
-
selectJsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
921
|
-
_selectJsonbAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['jsonbAgg'], As extends string | undefined = undefined>(this: T, arg: Expr, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_agg', As, NullableColumn<ArrayColumn<ExpressionOutput<T, Expr>>>>;
|
|
922
|
-
xmlAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['xmlAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
923
|
-
_xmlAgg<T extends Query, Expr extends Aggregate1ArgumentTypes<T>['xmlAgg']>(this: T, arg: Expr, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
924
|
-
selectXmlAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Aggregate1ArgumentTypes<T>['xmlAgg'], options?: AggregateOptions<T, As>): SelectAgg<T, 'xmlagg', As, NullableColumn<StringColumn>>;
|
|
925
|
-
_selectXmlAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: Aggregate1ArgumentTypes<T>['xmlAgg'], options?: AggregateOptions<T, As>): SelectAgg<T, 'xmlagg', As, NullableColumn<StringColumn>>;
|
|
926
|
-
jsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
927
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
928
|
-
}>>>;
|
|
929
|
-
_jsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
930
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
931
|
-
}>>>;
|
|
932
|
-
selectJsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_object_agg', As, NullableColumn<ColumnType<{
|
|
933
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
934
|
-
}>>>;
|
|
935
|
-
_selectJsonObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'json_object_agg', As, NullableColumn<ColumnType<{
|
|
936
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
937
|
-
}>>>;
|
|
938
|
-
jsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
939
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
940
|
-
}>>>;
|
|
941
|
-
_jsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>>(this: T, obj: Obj, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<ColumnType<{
|
|
942
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
943
|
-
}>>>;
|
|
944
|
-
selectJsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_object_agg', As, NullableColumn<ColumnType<{
|
|
945
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
946
|
-
}>>>;
|
|
947
|
-
_selectJsonbObjectAgg<T extends Query, Obj extends Record<string, Expression<T>>, As extends string | undefined = undefined>(this: T, obj: Obj, options?: AggregateOptions<T, As>): SelectAgg<T, 'jsonb_object_agg', As, NullableColumn<ColumnType<{
|
|
948
|
-
[K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'];
|
|
949
|
-
}>>>;
|
|
950
|
-
stringAgg<T extends Query>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
951
|
-
_stringAgg<T extends Query>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T>): SetQueryReturnsValue<T, NullableColumn<StringColumn>>;
|
|
952
|
-
selectStringAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T, As>): SelectAgg<T, 'string_agg', As, NullableColumn<StringColumn>>;
|
|
953
|
-
_selectStringAgg<T extends Query, As extends string | undefined = undefined>(this: T, arg: StringExpression<T>, delimiter: string, options?: AggregateOptions<T, As>): SelectAgg<T, 'string_agg', As, NullableColumn<StringColumn>>;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
declare type ClearStatement = 'with' | 'select' | 'where' | 'union' | 'using' | 'join' | 'group' | 'order' | 'having' | 'limit' | 'offset' | 'counters';
|
|
957
|
-
declare class Clear {
|
|
958
|
-
clear<T extends Query>(this: T, ...clears: ClearStatement[]): T;
|
|
959
|
-
_clear<T extends Query>(this: T, ...clears: ClearStatement[]): T;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
declare type ColumnInfo = {
|
|
963
|
-
defaultValue: unknown;
|
|
964
|
-
type: string;
|
|
965
|
-
maxLength: number | null;
|
|
966
|
-
nullable: boolean;
|
|
967
|
-
};
|
|
968
|
-
declare class ColumnInfoMethods {
|
|
969
|
-
columnInfo<T extends Query, Column extends keyof T['shape'] | undefined = undefined>(this: T, column?: Column): SetQueryReturnsColumnInfo<T, Column>;
|
|
970
|
-
_columnInfo<T extends Query, Column extends keyof T['shape'] | undefined = undefined>(this: T, column?: Column): SetQueryReturnsColumnInfo<T, Column>;
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
declare type DeleteArgs<T extends Query> = T['hasWhere'] extends true ? [forceAll?: boolean] : [true];
|
|
974
|
-
declare type DeleteResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T;
|
|
975
|
-
declare class Delete {
|
|
976
|
-
del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
977
|
-
_del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
978
|
-
delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
979
|
-
_delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
declare type ForQueryBuilder<Q extends Query> = Q & {
|
|
983
|
-
noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
984
|
-
_noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
985
|
-
skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
986
|
-
_skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
987
|
-
};
|
|
988
|
-
declare class For {
|
|
989
|
-
forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
990
|
-
_forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
991
|
-
forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
992
|
-
_forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
993
|
-
forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
994
|
-
_forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
995
|
-
forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
996
|
-
_forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
declare type FromArgs<T extends Query> = [
|
|
1000
|
-
first: string | Query | RawExpression | Exclude<keyof T['withData'], symbol | number>,
|
|
1001
|
-
second?: string | {
|
|
1002
|
-
as?: string;
|
|
1003
|
-
only?: boolean;
|
|
1004
|
-
}
|
|
1005
|
-
];
|
|
1006
|
-
declare type FromResult<T extends Query, Args extends FromArgs<T>> = Args[1] extends string ? SetQueryTableAlias<T, Args[1]> : Args[1] extends {
|
|
1007
|
-
as: string;
|
|
1008
|
-
} ? SetQueryTableAlias<T, Args[1]['as']> : Args[0] extends string ? SetQueryTableAlias<T, Args[0]> : Args[0] extends Query ? SetQueryTableAlias<T, AliasOrTable<Args[0]>> : T;
|
|
1009
|
-
declare class From {
|
|
1010
|
-
from<T extends Query, Args extends FromArgs<T>>(this: T, ...args: Args): FromResult<T, Args>;
|
|
1011
|
-
_from<T extends Query, Args extends FromArgs<T>>(this: T, ...args: Args): FromResult<T, Args>;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
declare type GetArg<T extends QueryBase> = StringKey<keyof T['selectable']> | RawExpression;
|
|
1015
|
-
declare type UnwrapRaw<T extends Query, Arg extends GetArg<T>> = Arg extends RawExpression ? Arg['__column'] : Exclude<Arg, RawExpression>;
|
|
1016
|
-
declare type GetResult<T extends Query, Arg extends GetArg<T>> = SetQueryReturnsValue<T, UnwrapRaw<T, Arg>>;
|
|
1017
|
-
declare type GetOptionalResult<T extends Query, Arg extends GetArg<T>> = SetQueryReturnsValueOptional<T, UnwrapRaw<T, Arg>>;
|
|
1018
|
-
declare type getValueKey = typeof getValueKey;
|
|
1019
|
-
declare const getValueKey: unique symbol;
|
|
1020
|
-
declare class QueryGet {
|
|
1021
|
-
get<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetResult<T, Arg>;
|
|
1022
|
-
_get<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetResult<T, Arg>;
|
|
1023
|
-
getOptional<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetOptionalResult<T, Arg>;
|
|
1024
|
-
_getOptional<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetOptionalResult<T, Arg>;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
declare type HavingArgObject<T extends Query, Agg extends keyof Aggregate1ArgumentTypes<T>> = {
|
|
1028
|
-
[Column in Exclude<Aggregate1ArgumentTypes<T>[Agg], RawExpression>]?: T['selectable'][Column]['column']['type'] | (ColumnOperators<T['selectable'], Column> & AggregateOptions<T>);
|
|
1029
|
-
};
|
|
1030
|
-
declare type HavingArg<T extends Query = Query> = ({
|
|
1031
|
-
[Agg in keyof Aggregate1ArgumentTypes<T>]?: HavingArgObject<T, Agg>;
|
|
1032
|
-
} & {
|
|
1033
|
-
count?: number | HavingArgObject<T, 'count'>;
|
|
1034
|
-
}) | Query | RawExpression;
|
|
1035
|
-
declare class Having {
|
|
1036
|
-
having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1037
|
-
_having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1038
|
-
havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1039
|
-
_havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
declare type JsonColumnName<T extends Pick<Query, 'selectable'>> = StringKey<{
|
|
1043
|
-
[K in keyof T['selectable']]: T['selectable'][K]['column']['dataType'] extends 'jsonb' ? K : never;
|
|
1044
|
-
}[keyof T['selectable']]>;
|
|
1045
|
-
declare type ColumnOrJsonMethod<T extends Query> = JsonColumnName<T> | JsonItem;
|
|
1046
|
-
declare type JsonSetResult<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string, Type extends ColumnType = Column extends keyof T['shape'] ? T['shape'][Column] : Column extends JsonItem ? Column['__json'][2] : ColumnType> = JsonItem<As, Type> & (Type extends ColumnType ? AddQuerySelect<T, Record<As, Type>> : T);
|
|
1047
|
-
declare type JsonPathQueryResult<T extends Query, As extends string, Type extends ColumnType> = JsonItem & AddQuerySelect<T, {
|
|
1048
|
-
[K in As]: Type;
|
|
1049
|
-
}>;
|
|
1050
|
-
declare class Json {
|
|
1051
|
-
json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1052
|
-
_json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1053
|
-
jsonSet<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
1054
|
-
as?: As;
|
|
1055
|
-
createIfMissing?: boolean;
|
|
1056
|
-
}): JsonSetResult<T, Column, As>;
|
|
1057
|
-
_jsonSet<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
1058
|
-
as?: As;
|
|
1059
|
-
createIfMissing?: boolean;
|
|
1060
|
-
}): JsonSetResult<T, Column, As>;
|
|
1061
|
-
jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1062
|
-
column: Column,
|
|
1063
|
-
path: Array<string | number>,
|
|
1064
|
-
value: unknown,
|
|
1065
|
-
options?: {
|
|
1066
|
-
as?: As;
|
|
1067
|
-
insertAfter?: boolean;
|
|
1068
|
-
}
|
|
1069
|
-
]): JsonSetResult<T, Column, As>;
|
|
1070
|
-
_jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
1071
|
-
as?: As;
|
|
1072
|
-
insertAfter?: boolean;
|
|
1073
|
-
}): JsonSetResult<T, Column, As>;
|
|
1074
|
-
jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1075
|
-
column: Column,
|
|
1076
|
-
path: Array<string | number>,
|
|
1077
|
-
options?: {
|
|
1078
|
-
as?: As;
|
|
1079
|
-
}
|
|
1080
|
-
]): JsonSetResult<T, Column, As>;
|
|
1081
|
-
_jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, options?: {
|
|
1082
|
-
as?: As;
|
|
1083
|
-
}): JsonSetResult<T, Column, As>;
|
|
1084
|
-
jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, ...args: [
|
|
1085
|
-
type: Type,
|
|
1086
|
-
column: ColumnOrJsonMethod<T>,
|
|
1087
|
-
path: string,
|
|
1088
|
-
as: As,
|
|
1089
|
-
options?: {
|
|
1090
|
-
vars?: string;
|
|
1091
|
-
silent?: boolean;
|
|
1092
|
-
}
|
|
1093
|
-
]): JsonPathQueryResult<T, As, Type>;
|
|
1094
|
-
_jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, type: Type, column: ColumnOrJsonMethod<T>, path: string, as: As, options?: {
|
|
1095
|
-
vars?: string;
|
|
1096
|
-
silent?: boolean;
|
|
1097
|
-
}): JsonPathQueryResult<T, As, Type>;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
declare type SelectArg<T extends QueryBase> = StringKey<keyof T['selectable']> | (T['relations'] extends Record<string, Relation> ? StringKey<keyof T['relations']> : never) | SelectAsArg<T>;
|
|
1101
|
-
declare type SelectAsArg<T extends QueryBase> = Record<string, StringKey<keyof T['selectable']> | RawExpression | ((q: T) => Query)>;
|
|
1102
|
-
declare type SelectResult<T extends Query, Args extends SelectArg<T>[], SelectAsArgs = SimpleSpread<FilterTuple<Args, SelectAsArg<T>>>> = AddQuerySelect<T, {
|
|
1103
|
-
[Arg in Args[number] as Arg extends keyof T['selectable'] ? T['selectable'][Arg]['as'] : Arg extends keyof T['relations'] ? Arg : never]: Arg extends keyof T['selectable'] ? T['selectable'][Arg]['column'] : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['returns'] extends 'many' ? ArrayOfColumnsObjects<T['relations'][Arg]['model']['result']> : T['relations'][Arg]['options']['required'] extends true ? ColumnsObject<T['relations'][Arg]['model']['result']> : NullableColumn<ColumnsObject<T['relations'][Arg]['model']['result']>> : never : never;
|
|
1104
|
-
} & {
|
|
1105
|
-
[K in keyof SelectAsArgs]: SelectAsArgs[K] extends keyof T['selectable'] ? T['selectable'][SelectAsArgs[K]]['column'] : SelectAsArgs[K] extends RawExpression ? SelectAsArgs[K]['__column'] : SelectAsArgs[K] extends (q: T) => Query ? SelectSubQueryResult<ReturnType<SelectAsArgs[K]>> : never;
|
|
1106
|
-
}>;
|
|
1107
|
-
declare type SelectSubQueryResult<Arg extends Query & {
|
|
1108
|
-
[isRequiredRelationKey]?: boolean;
|
|
1109
|
-
}> = Arg['returnType'] extends 'all' ? ArrayOfColumnsObjects<Arg['result']> : Arg['returnType'] extends 'valueOrThrow' ? Arg['result']['value'] : Arg['returnType'] extends 'pluck' ? PluckResultColumnType<Arg['result']['pluck']> : Arg[isRequiredRelationKey] extends true ? ColumnsObject<Arg['result']> : NullableColumn<ColumnsObject<Arg['result']>>;
|
|
1110
|
-
declare const addParserForRawExpression: (q: Query, key: string | getValueKey, raw: RawExpression) => void;
|
|
1111
|
-
declare const addParserForSelectItem: <T extends Query>(q: T, as: string | getValueKey | undefined, key: string, arg: RawExpression<ColumnType<unknown, Operators, unknown>> | Exclude<keyof T["selectable"], number | symbol> | ((q: T) => Query)) => string | RawExpression | Query;
|
|
1112
|
-
declare const addParserToQuery: (query: QueryData, key: string | getValueKey, parser: ColumnParser) => void;
|
|
1113
|
-
declare const processSelectArg: <T extends Query>(q: T, as: string | undefined, arg: SelectArg<T>, columnAs?: string | getValueKey) => SelectItem;
|
|
1114
|
-
declare class Select {
|
|
1115
|
-
select<T extends Query, K extends SelectArg<T>[]>(this: T, ...args: K): SelectResult<T, K>;
|
|
1116
|
-
_select<T extends Query, K extends SelectArg<T>[]>(this: T, ...args: K): SelectResult<T, K>;
|
|
1117
|
-
selectAll<T extends Query>(this: T): QuerySelectAll<T>;
|
|
1118
|
-
_selectAll<T extends Query>(this: T): QuerySelectAll<T>;
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
declare type ThenResult<Res> = (resolve?: (value: Res) => any, reject?: (error: any) => any) => Promise<Res | never>;
|
|
1122
|
-
declare const queryMethodByReturnType: Record<QueryReturnType, 'query' | 'arrays'>;
|
|
1123
|
-
declare class Then {
|
|
1124
|
-
then(this: Query, resolve?: (result: any) => any, reject?: (error: any) => any): Promise<any>;
|
|
1125
|
-
}
|
|
1126
|
-
declare const handleResult: CommonQueryData['handleResult'];
|
|
1127
|
-
declare const parseResult: (q: Query, returnType: QueryReturnType, result: QueryResult) => unknown;
|
|
1128
|
-
declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
|
|
1129
|
-
|
|
1130
|
-
declare class Transaction {
|
|
1131
|
-
transaction<T extends Query, Result>(this: T, cb: (query: T) => Promise<Result>): Promise<Result>;
|
|
1132
|
-
transacting<T extends Query>(this: T, query: Query): T;
|
|
1133
|
-
_transacting<T extends Query>(this: T, query: Query): T;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
declare type UnionArg<T extends Query> = (Omit<Query, 'result'> & {
|
|
1137
|
-
result: T['result'];
|
|
1138
|
-
}) | RawExpression;
|
|
1139
|
-
declare class Union {
|
|
1140
|
-
union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1141
|
-
_union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1142
|
-
unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1143
|
-
_unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1144
|
-
intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1145
|
-
_intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1146
|
-
intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1147
|
-
_intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1148
|
-
except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1149
|
-
_except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1150
|
-
exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1151
|
-
_exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
declare type UpsertData<T extends Query> = {
|
|
1155
|
-
update: UpdateData<T>;
|
|
1156
|
-
create: InsertData<T>;
|
|
1288
|
+
args: [relation: string] | [
|
|
1289
|
+
arg: string | QueryWithTable,
|
|
1290
|
+
conditions: Record<string, string | RawExpression> | RawExpression | ((q: unknown) => QueryBase)
|
|
1291
|
+
] | [
|
|
1292
|
+
arg: string | QueryWithTable,
|
|
1293
|
+
leftColumn: string | RawExpression,
|
|
1294
|
+
rightColumn: string | RawExpression
|
|
1295
|
+
] | [
|
|
1296
|
+
arg: string | QueryWithTable,
|
|
1297
|
+
leftColumn: string | RawExpression,
|
|
1298
|
+
op: string,
|
|
1299
|
+
rightColumn: string | RawExpression
|
|
1300
|
+
];
|
|
1157
1301
|
};
|
|
1158
|
-
declare type
|
|
1159
|
-
|
|
1160
|
-
|
|
1302
|
+
declare type WhereItem = (Omit<Record<string, unknown | Record<string, unknown | Query | RawExpression> | RawExpression>, 'NOT' | 'AND' | 'OR' | 'IN' | 'EXISTS' | 'ON' | 'ON_JSON_PATH_EQUALS'> & {
|
|
1303
|
+
NOT?: MaybeArray<WhereItem>;
|
|
1304
|
+
AND?: MaybeArray<WhereItem>;
|
|
1305
|
+
OR?: MaybeArray<WhereItem>[];
|
|
1306
|
+
IN?: MaybeArray<WhereInItem>;
|
|
1307
|
+
EXISTS?: MaybeArray<JoinItem['args']>;
|
|
1308
|
+
ON?: WhereOnItem | WhereJsonPathEqualsItem;
|
|
1309
|
+
}) | ((q: unknown) => QueryBase) | Query | RawExpression;
|
|
1310
|
+
declare type WhereInItem = {
|
|
1311
|
+
columns: string[];
|
|
1312
|
+
values: unknown[][] | Query | RawExpression;
|
|
1161
1313
|
};
|
|
1162
|
-
declare
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
schema: TableSchema<Shape>;
|
|
1178
|
-
type: ColumnShapeOutput<Shape>;
|
|
1179
|
-
inputType: ColumnShapeInput<Shape>;
|
|
1180
|
-
returnType: 'all';
|
|
1181
|
-
then: ThenResult<Pick<ColumnShapeOutput<Shape>, DefaultSelectColumns<Shape>[number]>[]>;
|
|
1182
|
-
query: QueryData;
|
|
1183
|
-
columns: (keyof ColumnShapeOutput<Shape>)[];
|
|
1184
|
-
defaultSelectColumns: DefaultSelectColumns<Shape>;
|
|
1185
|
-
columnsParsers?: ColumnsParsers;
|
|
1186
|
-
result: Pick<Shape, DefaultSelectColumns<Shape>[number]>;
|
|
1187
|
-
hasSelect: false;
|
|
1188
|
-
hasWhere: boolean;
|
|
1189
|
-
selectable: {
|
|
1190
|
-
[K in keyof Shape]: {
|
|
1191
|
-
as: K;
|
|
1192
|
-
column: Shape[K];
|
|
1193
|
-
};
|
|
1194
|
-
} & {
|
|
1195
|
-
[K in keyof Shape as `${Table}.${StringKey<K>}`]: {
|
|
1196
|
-
as: K;
|
|
1197
|
-
column: Shape[K];
|
|
1198
|
-
};
|
|
1314
|
+
declare type WhereJsonPathEqualsItem = [
|
|
1315
|
+
leftColumn: string,
|
|
1316
|
+
leftPath: string,
|
|
1317
|
+
rightColumn: string,
|
|
1318
|
+
rightPath: string
|
|
1319
|
+
];
|
|
1320
|
+
declare type WhereOnItem = {
|
|
1321
|
+
joinFrom: WhereOnJoinItem;
|
|
1322
|
+
joinTo: WhereOnJoinItem;
|
|
1323
|
+
on: [leftFullColumn: string, rightFullColumn: string] | [leftFullColumn: string, op: string, rightFullColumn: string];
|
|
1324
|
+
};
|
|
1325
|
+
declare type WhereOnJoinItem = {
|
|
1326
|
+
table?: string;
|
|
1327
|
+
query: {
|
|
1328
|
+
as?: string;
|
|
1199
1329
|
};
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
adapter: Adapter;
|
|
1211
|
-
queryBuilder: Db;
|
|
1212
|
-
table: Table;
|
|
1213
|
-
shape: Shape;
|
|
1214
|
-
whereQueryBuilder: typeof WhereQueryBuilder;
|
|
1215
|
-
onQueryBuilder: typeof OnQueryBuilder;
|
|
1216
|
-
constructor(adapter: Adapter, queryBuilder: Db, table: Table, shape: Shape, options: DbTableOptions);
|
|
1217
|
-
}
|
|
1218
|
-
declare type DbResult<CT extends ColumnTypesBase> = Db & {
|
|
1219
|
-
<Table extends string, Shape extends ColumnsShape = ColumnsShape>(table: Table, shape?: ((t: CT) => Shape) | Shape, options?: DbTableOptions): Db<Table, Shape>;
|
|
1220
|
-
adapter: Adapter;
|
|
1221
|
-
destroy: Adapter['destroy'];
|
|
1330
|
+
} | string;
|
|
1331
|
+
declare type AggregateItemOptions = {
|
|
1332
|
+
as?: string;
|
|
1333
|
+
distinct?: boolean;
|
|
1334
|
+
order?: OrderItem[];
|
|
1335
|
+
filter?: WhereItem;
|
|
1336
|
+
filterOr?: WhereItem[];
|
|
1337
|
+
withinGroup?: boolean;
|
|
1338
|
+
over?: string;
|
|
1339
|
+
window?: WindowItem;
|
|
1222
1340
|
};
|
|
1223
|
-
declare type
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1341
|
+
declare type SortDir = 'ASC' | 'DESC';
|
|
1342
|
+
declare type OrderItem = string | Record<string, SortDir | {
|
|
1343
|
+
dir: SortDir;
|
|
1344
|
+
nulls: 'FIRST' | 'LAST';
|
|
1345
|
+
}> | RawExpression;
|
|
1346
|
+
declare type AggregateItemArg = Expression | Record<string, Expression> | [Expression, string];
|
|
1347
|
+
declare type AggregateItem = {
|
|
1348
|
+
function: string;
|
|
1349
|
+
arg?: AggregateItemArg;
|
|
1350
|
+
options: AggregateItemOptions;
|
|
1227
1351
|
};
|
|
1228
|
-
declare
|
|
1229
|
-
|
|
1230
|
-
integer: () => IntegerColumn;
|
|
1231
|
-
bigint: () => BigIntColumn;
|
|
1232
|
-
numeric: <Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(precision?: Precision | undefined, scale?: Scale | undefined) => DecimalColumn<Precision, Scale>;
|
|
1233
|
-
decimal: <Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(precision?: Precision_1 | undefined, scale?: Scale_1 | undefined) => DecimalColumn<Precision_1, Scale_1>;
|
|
1234
|
-
real: () => RealColumn;
|
|
1235
|
-
doublePrecision: () => DoublePrecisionColumn;
|
|
1236
|
-
smallSerial: () => SmallSerialColumn;
|
|
1237
|
-
serial: () => SerialColumn;
|
|
1238
|
-
bigSerial: () => BigSerialColumn;
|
|
1239
|
-
money: () => MoneyColumn;
|
|
1240
|
-
varchar: <Limit extends number | undefined = undefined>(limit?: Limit | undefined) => VarCharColumn<Limit>;
|
|
1241
|
-
char: <Limit_1 extends number | undefined = undefined>(limit?: Limit_1 | undefined) => CharColumn<Limit_1>;
|
|
1242
|
-
text: () => TextColumn;
|
|
1243
|
-
string: () => TextColumn;
|
|
1244
|
-
bytea: () => ByteaColumn;
|
|
1245
|
-
date: () => DateColumn;
|
|
1246
|
-
timestamp: <Precision_2 extends number | undefined = undefined>(precision?: Precision_2 | undefined) => TimestampColumn<Precision_2>;
|
|
1247
|
-
timestampWithTimeZone: <Precision_3 extends number | undefined = undefined>(precision?: Precision_3 | undefined) => TimestampWithTimeZoneColumn<Precision_3>;
|
|
1248
|
-
time: <Precision_4 extends number | undefined = undefined>(precision?: Precision_4 | undefined) => TimeColumn<Precision_4>;
|
|
1249
|
-
timeWithTimeZone: <Precision_5 extends number | undefined = undefined>(precision?: Precision_5 | undefined) => TimeWithTimeZoneColumn<Precision_5>;
|
|
1250
|
-
interval: <Fields extends string | undefined = undefined, Precision_6 extends number | undefined = undefined>(fields?: Fields | undefined, precision?: Precision_6 | undefined) => IntervalColumn<Fields, Precision_6>;
|
|
1251
|
-
boolean: () => BooleanColumn;
|
|
1252
|
-
enum: <U extends string, T extends [U, ...U[]]>(dataType: string, type: T) => EnumColumn<U, T>;
|
|
1253
|
-
point: () => PointColumn;
|
|
1254
|
-
line: () => LineColumn;
|
|
1255
|
-
lseg: () => LsegColumn;
|
|
1256
|
-
box: () => BoxColumn;
|
|
1257
|
-
path: () => PathColumn;
|
|
1258
|
-
polygon: () => PolygonColumn;
|
|
1259
|
-
circle: () => CircleColumn;
|
|
1260
|
-
cidr: () => CidrColumn;
|
|
1261
|
-
inet: () => InetColumn;
|
|
1262
|
-
macaddr: () => MacAddrColumn;
|
|
1263
|
-
macaddr8: () => MacAddr8Column;
|
|
1264
|
-
bit: <Length extends number>(length: Length) => BitColumn<Length>;
|
|
1265
|
-
bitVarying: <Length_1 extends number | undefined = undefined>(length?: Length_1 | undefined) => BitVaryingColumn<Length_1 | undefined>;
|
|
1266
|
-
tsvector: () => TsVectorColumn;
|
|
1267
|
-
tsquery: () => TsQueryColumn;
|
|
1268
|
-
uuid: () => UUIDColumn;
|
|
1269
|
-
xml: () => XMLColumn;
|
|
1270
|
-
json: <Type extends JSONTypeAny>(schemaOrFn: Type | ((j: {
|
|
1271
|
-
set: <Value extends JSONTypeAny>(valueType: Value) => JSONSet<Value>;
|
|
1272
|
-
tuple: <T_1 extends [] | JSONTupleItems, Rest extends JSONTypeAny | null = null>(items: T_1, rest?: Rest) => JSONTuple<T_1, Rest>;
|
|
1273
|
-
union: <T_2 extends [JSONTypeAny, JSONTypeAny, ...JSONTypeAny[]]>(types: T_2) => JSONUnion<T_2>;
|
|
1274
|
-
any: () => JSONAny;
|
|
1275
|
-
bigint: () => JSONBigInt;
|
|
1276
|
-
boolean: () => JSONBoolean;
|
|
1277
|
-
date: () => JSONDate;
|
|
1278
|
-
nan: () => JSONNaN;
|
|
1279
|
-
never: () => JSONNever;
|
|
1280
|
-
null: () => JSONNull;
|
|
1281
|
-
number: () => JSONNumber;
|
|
1282
|
-
string: () => JSONString;
|
|
1283
|
-
undefined: () => JSONUndefined;
|
|
1284
|
-
unknown: () => JSONUnknown;
|
|
1285
|
-
void: () => JSONVoid;
|
|
1286
|
-
array: <Type_1 extends JSONTypeAny>(element: Type_1) => JSONArray<Type_1, "many">;
|
|
1287
|
-
discriminatedUnion: <Discriminator extends string, DiscriminatorValue extends Primitive, Types extends [JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, JSONDiscriminatedObject<Discriminator, DiscriminatorValue>, ...JSONDiscriminatedObject<Discriminator, DiscriminatorValue>[]]>(discriminator: Discriminator, options: Types) => JSONDiscriminatedUnion<Discriminator, DiscriminatorValue, Types[number]>;
|
|
1288
|
-
enum: <U_1 extends string, T_3 extends [U_1, ...U_1[]]>(options: T_3) => JSONEnum<U_1, T_3>;
|
|
1289
|
-
instanceOf: <T_4 extends new (...args: any[]) => any>(cls: T_4) => JSONInstanceOf<T_4>;
|
|
1290
|
-
intersection: <Left extends JSONTypeAny, Right extends JSONTypeAny>(left: Left, right: Right) => JSONIntersection<Left, Right>;
|
|
1291
|
-
lazy: <T_5 extends JSONTypeAny>(fn: () => T_5) => JSONLazy<T_5>;
|
|
1292
|
-
literal: <T_6 extends Primitive>(value: T_6) => JSONLiteral<T_6>;
|
|
1293
|
-
map: <Key extends JSONTypeAny, Value_1 extends JSONTypeAny>(keyType: Key, valueType: Value_1) => JSONMap<Key, Value_1>;
|
|
1294
|
-
nativeEnum: <T_7 extends EnumLike>(givenEnum: T_7) => JSONNativeEnum<T_7>;
|
|
1295
|
-
nullable: <T_8 extends JSONTypeAny>(type: T_8) => JSONNullable<T_8>;
|
|
1296
|
-
nullish: <T_9 extends JSONTypeAny>(type: T_9) => JSONNullish<T_9>;
|
|
1297
|
-
object: <T_10 extends JSONObjectShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends JSONTypeAny = JSONTypeAny>(shape: T_10) => JSONObject<T_10, UnknownKeys, Catchall, JSONTypeAny extends Catchall ? addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never : (addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
1298
|
-
[k: string]: Catchall["type"];
|
|
1299
|
-
} extends infer T_12 ? { [k_2 in keyof T_12]: ((addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }> extends infer T_11 ? { [k in keyof T_11]: addQuestionMarks<{ [k_1 in keyof T_10]: T_10[k_1]["type"]; }>[k]; } : never) & {
|
|
1300
|
-
[k: string]: Catchall["type"];
|
|
1301
|
-
})[k_2]; } : never>;
|
|
1302
|
-
optional: <T_13 extends JSONTypeAny>(type: T_13) => JSONOptional<T_13>;
|
|
1303
|
-
record: typeof record;
|
|
1304
|
-
}) => Type)) => JSONColumn<Type>;
|
|
1305
|
-
jsonText: () => JSONTextColumn;
|
|
1306
|
-
array: <Item extends ColumnType<unknown, Operators, unknown>>(item: Item) => ArrayColumn<Item>;
|
|
1307
|
-
timestamps<T_14 extends ColumnType<unknown, Operators, unknown>>(this: {
|
|
1308
|
-
timestamp(): T_14;
|
|
1309
|
-
}): {
|
|
1310
|
-
createdAt: T_14 & {
|
|
1311
|
-
hasDefault: true;
|
|
1312
|
-
};
|
|
1313
|
-
updatedAt: T_14 & {
|
|
1314
|
-
hasDefault: true;
|
|
1315
|
-
};
|
|
1316
|
-
};
|
|
1317
|
-
primaryKey(columns: string[], options?: {
|
|
1318
|
-
name?: string | undefined;
|
|
1319
|
-
} | undefined): {};
|
|
1320
|
-
index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
|
|
1321
|
-
unique(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): {};
|
|
1322
|
-
foreignKey: {
|
|
1323
|
-
<Model extends ForeignKeyModelWithColumns, Columns extends [Exclude<keyof InstanceType<Model>["columns"]["shape"], number | symbol>, ...Exclude<keyof InstanceType<Model>["columns"]["shape"], number | symbol>[]]>(columns: string[], fn: () => Model, foreignColumns: Columns, options?: ForeignKeyOptions | undefined): {};
|
|
1324
|
-
<Table extends string, Columns_1 extends [string, ...string[]]>(columns: string[], table: Table, foreignColumns: Columns_1, options?: ForeignKeyOptions | undefined): {};
|
|
1325
|
-
};
|
|
1326
|
-
}>({ log, logger, columnTypes: ct, ...options }: DbOptions<CT>) => DbResult<CT>;
|
|
1327
|
-
|
|
1328
|
-
declare type WithArgsOptions = Omit<WithOptions, 'columns'> & {
|
|
1329
|
-
columns?: boolean | string[];
|
|
1352
|
+
declare type ColumnOperators<S extends SelectableBase, Column extends keyof S> = {
|
|
1353
|
+
[O in keyof S[Column]['column']['operators']]?: S[Column]['column']['operators'][O]['type'];
|
|
1330
1354
|
};
|
|
1331
|
-
declare type
|
|
1332
|
-
declare type
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1355
|
+
declare type HavingItemObject = Record<string, unknown>;
|
|
1356
|
+
declare type HavingItem = Record<string, HavingItemObject> | {
|
|
1357
|
+
count?: number | HavingItemObject;
|
|
1358
|
+
} | Query | RawExpression;
|
|
1359
|
+
declare type WindowItem = Record<string, WindowDeclaration | RawExpression>;
|
|
1360
|
+
declare type WindowDeclaration = {
|
|
1361
|
+
partitionBy?: Expression | Expression[];
|
|
1362
|
+
order?: OrderItem;
|
|
1363
|
+
};
|
|
1364
|
+
declare type UnionItem = Query | RawExpression;
|
|
1365
|
+
declare type UnionKind = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' | 'EXCEPT' | 'EXCEPT ALL';
|
|
1366
|
+
declare type OnConflictItem = string | string[] | RawExpression;
|
|
1367
|
+
declare type OnConflictMergeUpdate = string | string[] | Record<string, unknown> | RawExpression;
|
|
1342
1368
|
|
|
1343
1369
|
declare type ToSqlCtx = {
|
|
1344
1370
|
whereQueryBuilder: typeof WhereQueryBuilder;
|
|
@@ -1348,6 +1374,10 @@ declare type ToSqlCtx = {
|
|
|
1348
1374
|
};
|
|
1349
1375
|
declare const toSql: (model: Query, values?: unknown[]) => Sql;
|
|
1350
1376
|
|
|
1377
|
+
declare type SomeIsTrue<T extends unknown[]> = T extends [
|
|
1378
|
+
infer Head,
|
|
1379
|
+
...infer Tail
|
|
1380
|
+
] ? Head extends true ? true : SomeIsTrue<Tail> : false;
|
|
1351
1381
|
declare type MaybeArray<T> = T | T[];
|
|
1352
1382
|
declare type SetOptional<T, K extends PropertyKey> = Omit<T, K> & {
|
|
1353
1383
|
[P in K]?: P extends keyof T ? T[P] : never;
|
|
@@ -2140,9 +2170,15 @@ declare type ColumnsShape = Record<string, ColumnType>;
|
|
|
2140
2170
|
declare type ColumnShapeOutput<Shape extends ColumnsShape> = {
|
|
2141
2171
|
[K in keyof Shape]: ColumnOutput<Shape[K]>;
|
|
2142
2172
|
};
|
|
2143
|
-
declare type
|
|
2173
|
+
declare type OptionalColumnsForInput<Shape extends ColumnsShape> = {
|
|
2174
|
+
[K in keyof Shape]: SomeIsTrue<[
|
|
2175
|
+
Shape[K]['isNullable'],
|
|
2176
|
+
Shape[K]['hasDefault']
|
|
2177
|
+
]> extends true ? K : never;
|
|
2178
|
+
}[keyof Shape];
|
|
2179
|
+
declare type ColumnShapeInput<Shape extends ColumnsShape> = SetOptional<{
|
|
2144
2180
|
[K in keyof Shape]: ColumnInput<Shape[K]>;
|
|
2145
|
-
}
|
|
2181
|
+
}, OptionalColumnsForInput<Shape>>;
|
|
2146
2182
|
declare class ColumnsObject<Shape extends ColumnsShape> extends ColumnType<{
|
|
2147
2183
|
[K in keyof Shape]: Shape[K]['type'];
|
|
2148
2184
|
}, typeof Operators.any> {
|
|
@@ -2483,13 +2519,16 @@ declare class DoublePrecisionColumn extends NumberAsStringBaseColumn {
|
|
|
2483
2519
|
declare class SmallSerialColumn extends IntegerBaseColumn {
|
|
2484
2520
|
dataType: "smallserial";
|
|
2485
2521
|
parseItem: typeof parseInt;
|
|
2522
|
+
hasDefault: true;
|
|
2486
2523
|
}
|
|
2487
2524
|
declare class SerialColumn extends IntegerBaseColumn {
|
|
2488
2525
|
dataType: "serial";
|
|
2489
2526
|
parseItem: typeof parseInt;
|
|
2527
|
+
hasDefault: true;
|
|
2490
2528
|
}
|
|
2491
2529
|
declare class BigSerialColumn extends NumberAsStringBaseColumn {
|
|
2492
2530
|
dataType: "bigserial";
|
|
2531
|
+
hasDefault: true;
|
|
2493
2532
|
}
|
|
2494
2533
|
|
|
2495
2534
|
declare type BaseStringData = ColumnData & {
|
|
@@ -4315,4 +4354,4 @@ declare class UnhandledTypeError extends PormInternalError {
|
|
|
4315
4354
|
constructor(value: never);
|
|
4316
4355
|
}
|
|
4317
4356
|
|
|
4318
|
-
export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, GetTypeOrRaw, GetTypesOrRaw, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, Insert, InsertData, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators,
|
|
4357
|
+
export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, GetTypeOrRaw, GetTypesOrRaw, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, Insert, InsertData, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrderArg, OrderItem, OutputTypeOfTuple, OutputTypeOfTupleWithRest, OwnTypeProps, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, Primitive, PropertyKeyUnionToArray, Query, QueryArraysResult, QueryBase, QueryCallbacks, QueryData, QueryGet, QueryInput, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryResultRow, QueryReturnType, QuerySelectAll, QueryUpsert, QueryWithTable, RawExpression, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationsBase, Select, SelectAgg, SelectArg, SelectFunctionItem, SelectItem, SelectQueryData, Selectable, SelectableBase, SerialColumn, SetOptional, SetQueryJoinedTables, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumnInfo, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWindows, SetQueryWith, SimpleSpread, SingleColumnIndexOptions, SmallIntColumn, SmallSerialColumn, SomeIsTrue, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TableSchema, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, ToSqlCtx, Transaction, TransactionAdapter, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionToArray, UnionToIntersection, UnionToOvlds, UnknownKeysParam, Update, UpdateData, UpdateQueryData, UpsertData, UpsertResult, UpsertThis, ValidationContext, VarCharColumn, Where, WhereArg, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowFunctionOptions, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addQuestionMarks, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, baseObjectOutputType, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, flatten, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getTableData, getValidEnumValues, getValueKey, handleResult, identity, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryKeysOfNotSimpleQuery, queryMethodByReturnType, quote, raw, record, relationQueryKey, removeFromQuery, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, tuple, union };
|