pqb 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +254 -246
- package/dist/index.esm.js +667 -724
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +667 -724
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/query.ts +1 -0
- package/src/queryMethods/join.test.ts +2 -2
- package/src/queryMethods/join.ts +18 -12
- package/src/queryMethods/queryMethods.test.ts +123 -112
- package/src/queryMethods/queryMethods.ts +10 -12
- package/src/queryMethods/select.test.ts +6 -6
- package/src/queryMethods/then.ts +3 -1
- package/src/queryMethods/where.test.ts +1 -1
- package/src/queryMethods/where.ts +8 -3
- package/src/relations.ts +1 -1
- package/src/sql/aggregate.ts +17 -14
- package/src/sql/columnInfo.ts +5 -5
- package/src/sql/delete.ts +12 -12
- package/src/sql/distinct.ts +5 -5
- package/src/sql/fromAndAs.ts +14 -10
- package/src/sql/having.ts +15 -15
- package/src/sql/insert.ts +24 -23
- package/src/sql/join.ts +73 -111
- package/src/sql/orderBy.ts +4 -4
- package/src/sql/select.ts +26 -16
- package/src/sql/toSql.ts +28 -15
- package/src/sql/truncate.ts +5 -4
- package/src/sql/types.ts +2 -0
- package/src/sql/update.ts +14 -14
- package/src/sql/where.ts +183 -223
- package/src/sql/with.ts +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -54,15 +54,20 @@ declare type JoinResult<T extends Query, Args extends JoinArgs<T>, A extends Que
|
|
|
54
54
|
} : never : never : never>;
|
|
55
55
|
declare type JoinCallbackArg<T extends QueryBase> = Query | keyof T['withData'] | keyof T['relations'];
|
|
56
56
|
declare type JoinCallback<T extends QueryBase, Arg extends JoinCallbackArg<T>> = (q: OnQueryBuilder<T, Arg extends keyof T['withData'] ? T['withData'][Arg] extends WithDataItem ? {
|
|
57
|
+
query: QueryData;
|
|
57
58
|
table: T['withData'][Arg]['table'];
|
|
58
59
|
tableAlias: undefined;
|
|
59
|
-
|
|
60
|
+
clone(): QueryBase;
|
|
60
61
|
selectable: {
|
|
61
62
|
[K in keyof T['withData'][Arg]['shape'] as `${T['withData'][Arg]['table']}.${StringKey<K>}`]: {
|
|
62
63
|
as: StringKey<K>;
|
|
63
64
|
column: T['withData'][Arg]['shape'][K];
|
|
64
65
|
};
|
|
65
66
|
};
|
|
67
|
+
shape: T['withData'][Arg]['shape'];
|
|
68
|
+
__model: Query;
|
|
69
|
+
relations: RelationsBase;
|
|
70
|
+
withData: WithDataBase;
|
|
66
71
|
} : never : Arg extends Query ? Arg : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['model'] : never : never>) => OnQueryBuilder;
|
|
67
72
|
declare type JoinCallbackResult<T extends Query, Arg extends JoinCallbackArg<T>> = AddQueryJoinedTable<T, Arg extends Query ? Arg : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['model'] : Arg extends keyof T['withData'] ? T['withData'][Arg] extends WithDataItem ? {
|
|
68
73
|
table: T['withData'][Arg]['table'];
|
|
@@ -99,7 +104,6 @@ declare class Join {
|
|
|
99
104
|
_fullOuterJoin<T extends Query, Args extends JoinArgs<T>>(this: T, ...args: Args): JoinResult<T, Args>;
|
|
100
105
|
_fullOuterJoin<T extends Query, Arg extends JoinCallbackArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinCallbackResult<T, Arg>;
|
|
101
106
|
}
|
|
102
|
-
declare type PickQueryForSelect<T extends QueryBase = QueryBase> = Pick<T, 'table' | 'tableAlias' | 'selectable'>;
|
|
103
107
|
declare type OnArgs<Q extends {
|
|
104
108
|
selectable: SelectableBase;
|
|
105
109
|
}> = [leftColumn: keyof Q['selectable'], rightColumn: keyof Q['selectable']] | [
|
|
@@ -117,16 +121,11 @@ declare type OnJsonPathEqualsArgs<T extends QueryBase> = [
|
|
|
117
121
|
rightColumn: keyof T['selectable'],
|
|
118
122
|
rightPath: string
|
|
119
123
|
];
|
|
120
|
-
declare class OnQueryBuilder<S extends QueryBase = QueryBase, J extends
|
|
121
|
-
selectable: S['selectable'] & J['selectable'];
|
|
124
|
+
declare class OnQueryBuilder<S extends QueryBase = QueryBase, J extends QueryBase = QueryBase> extends WhereQueryBuilder<Omit<J, 'selectable'> & {
|
|
125
|
+
selectable: Omit<S['selectable'], keyof S['shape']> & J['selectable'];
|
|
122
126
|
}> implements QueryBase {
|
|
123
|
-
joinTo: QueryBase
|
|
124
|
-
constructor(q:
|
|
125
|
-
table?: string;
|
|
126
|
-
query: {
|
|
127
|
-
as?: string;
|
|
128
|
-
};
|
|
129
|
-
}, joinTo: QueryBase | string);
|
|
127
|
+
joinTo: QueryBase;
|
|
128
|
+
constructor(q: QueryBase | string, shape: ColumnsShape, joinTo: QueryBase);
|
|
130
129
|
on<T extends this>(this: T, ...args: OnArgs<T>): T;
|
|
131
130
|
_on<T extends this>(this: T, ...args: OnArgs<T>): T;
|
|
132
131
|
orOn<T extends this>(this: T, ...args: OnArgs<T>): T;
|
|
@@ -168,6 +167,7 @@ declare const addWhereIn: <T extends QueryBase>(q: T, and: boolean, arg: unknown
|
|
|
168
167
|
declare abstract class Where implements QueryBase {
|
|
169
168
|
abstract clone<T extends this>(this: T): T;
|
|
170
169
|
abstract selectable: SelectableBase;
|
|
170
|
+
abstract shape: ColumnsShape;
|
|
171
171
|
abstract relations: RelationsBase;
|
|
172
172
|
abstract withData: WithDataBase;
|
|
173
173
|
abstract __model: Query;
|
|
@@ -220,14 +220,13 @@ declare abstract class Where implements QueryBase {
|
|
|
220
220
|
_orWhereNotExists<T extends Where, Arg extends JoinCallbackArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): WhereResult<T>;
|
|
221
221
|
}
|
|
222
222
|
declare class WhereQueryBuilder<Q extends QueryBase = QueryBase> extends Where implements QueryBase {
|
|
223
|
-
table: Q['table'];
|
|
224
|
-
tableAlias: Q['tableAlias'];
|
|
225
223
|
query: QueryData;
|
|
226
224
|
selectable: Q['selectable'];
|
|
225
|
+
shape: Q['shape'];
|
|
227
226
|
__model: Query;
|
|
228
227
|
relations: {};
|
|
229
228
|
withData: {};
|
|
230
|
-
constructor(
|
|
229
|
+
constructor(q: QueryBase | string, shape: ColumnsShape);
|
|
231
230
|
clone<T extends this>(this: T): T;
|
|
232
231
|
}
|
|
233
232
|
|
|
@@ -431,7 +430,7 @@ declare type BaseRelation = {
|
|
|
431
430
|
key: string;
|
|
432
431
|
model: QueryWithTable;
|
|
433
432
|
query: QueryWithTable;
|
|
434
|
-
joinQuery(fromQuery:
|
|
433
|
+
joinQuery(fromQuery: QueryBase, toQuery: QueryBase): QueryBase;
|
|
435
434
|
nestedCreateQuery: Query;
|
|
436
435
|
nestedInsert?: BelongsToNestedInsert | HasOneNestedInsert | HasManyNestedInsert;
|
|
437
436
|
nestedUpdate?: BelongsToNestedUpdate | HasOneNestedUpdate | HasManyNestedUpdate;
|
|
@@ -608,7 +607,9 @@ declare type CommonQueryData = {
|
|
|
608
607
|
from?: string | Query | RawExpression;
|
|
609
608
|
and?: WhereItem[];
|
|
610
609
|
or?: WhereItem[][];
|
|
610
|
+
coalesceValue?: unknown | RawExpression;
|
|
611
611
|
parsers?: ColumnsParsers;
|
|
612
|
+
notFoundDefault?: unknown;
|
|
612
613
|
defaults?: Record<string, unknown>;
|
|
613
614
|
beforeQuery?: BeforeCallback<Query>[];
|
|
614
615
|
afterQuery?: AfterCallback<Query>[];
|
|
@@ -822,73 +823,6 @@ declare type UnionKind = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' |
|
|
|
822
823
|
declare type OnConflictItem = string | string[] | RawExpression;
|
|
823
824
|
declare type OnConflictMergeUpdate = string | string[] | Record<string, unknown> | RawExpression;
|
|
824
825
|
|
|
825
|
-
declare const toSql: (model: Query, values?: unknown[]) => Sql;
|
|
826
|
-
|
|
827
|
-
declare type MaybeArray<T> = T | T[];
|
|
828
|
-
declare type SetOptional<T, K extends PropertyKey> = Omit<T, K> & {
|
|
829
|
-
[P in K]?: P extends keyof T ? T[P] : never;
|
|
830
|
-
};
|
|
831
|
-
declare type GetTypesOrRaw<T extends [...unknown[]]> = T extends [
|
|
832
|
-
infer Head,
|
|
833
|
-
...infer Tail
|
|
834
|
-
] ? [GetTypeOrRaw<Head>, ...GetTypesOrRaw<Tail>] : [];
|
|
835
|
-
declare type GetTypeOrRaw<T> = T | RawExpression;
|
|
836
|
-
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
837
|
-
declare type UnionToOvlds<U> = UnionToIntersection<U extends any ? (f: U) => void : never>;
|
|
838
|
-
declare type PopPropertyKeyUnion<U> = UnionToOvlds<U> extends (a: infer A extends PropertyKey) => void ? A : never;
|
|
839
|
-
declare type IsUnion$1<T> = [T] extends [UnionToIntersection<T>] ? false : true;
|
|
840
|
-
declare type PropertyKeyUnionToArray<T, A extends PropertyKey[] = []> = IsUnion$1<T> extends true ? PropertyKeyUnionToArray<Exclude<T, PopPropertyKeyUnion<T>>, [
|
|
841
|
-
PopPropertyKeyUnion<T>,
|
|
842
|
-
...A
|
|
843
|
-
]> : [T, ...A];
|
|
844
|
-
declare type OptionalPropertyNames<T> = {
|
|
845
|
-
[K in keyof T]-?: {} extends {
|
|
846
|
-
[P in K]: T[K];
|
|
847
|
-
} ? K : never;
|
|
848
|
-
}[keyof T];
|
|
849
|
-
declare type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
850
|
-
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
851
|
-
};
|
|
852
|
-
declare type Id<T> = T extends infer U ? {
|
|
853
|
-
[K in keyof U]: U[K];
|
|
854
|
-
} : never;
|
|
855
|
-
declare type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
856
|
-
declare type Spread<A extends readonly [...any]> = A extends [
|
|
857
|
-
infer L,
|
|
858
|
-
...infer R
|
|
859
|
-
] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
860
|
-
declare type SimpleSpread<A extends readonly [...any]> = A extends [
|
|
861
|
-
infer L,
|
|
862
|
-
...infer R
|
|
863
|
-
] ? L & SimpleSpread<R> : {};
|
|
864
|
-
declare type FilterTuple<T extends readonly any[], E> = T extends [
|
|
865
|
-
infer F,
|
|
866
|
-
...infer R
|
|
867
|
-
] ? [F] extends [E] ? [F, ...FilterTuple<R, E>] : FilterTuple<R, E> : [];
|
|
868
|
-
declare type CoalesceString<Left extends string | undefined, Right extends string> = Left extends undefined ? Right : Left;
|
|
869
|
-
declare function applyMixins(derivedCtor: any, constructors: any[]): void;
|
|
870
|
-
declare const joinTruthy: (...strings: (string | false | undefined)[]) => string;
|
|
871
|
-
declare const getClonedQueryData: (query: QueryData) => QueryData;
|
|
872
|
-
declare const getQueryAs: (q: {
|
|
873
|
-
table?: string;
|
|
874
|
-
query: {
|
|
875
|
-
as?: string;
|
|
876
|
-
};
|
|
877
|
-
}) => string;
|
|
878
|
-
declare const toArray: <T>(item: T) => T extends unknown[] ? T : [T];
|
|
879
|
-
declare const noop: () => void;
|
|
880
|
-
declare type EmptyObject = typeof emptyObject;
|
|
881
|
-
declare const emptyObject: {};
|
|
882
|
-
|
|
883
|
-
declare type ThenResult<Res> = (resolve?: (value: Res) => any, reject?: (error: any) => any) => Promise<Res | never>;
|
|
884
|
-
declare const queryMethodByReturnType: Record<QueryReturnType, 'query' | 'arrays'>;
|
|
885
|
-
declare class Then {
|
|
886
|
-
then(this: Query, resolve?: (result: any) => any, reject?: (error: any) => any): Promise<any>;
|
|
887
|
-
}
|
|
888
|
-
declare const handleResult: CommonQueryData['handleResult'];
|
|
889
|
-
declare const parseResult: (q: Query, returnType: QueryReturnType, result: QueryResult) => unknown;
|
|
890
|
-
declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
|
|
891
|
-
|
|
892
826
|
declare type AggregateArg<T extends Query> = Expression<T> | Record<string, Expression<T>> | [Expression<T>, string];
|
|
893
827
|
declare type AggregateOptions<T extends Query = Query, As extends string | undefined = any> = {
|
|
894
828
|
as?: As;
|
|
@@ -1019,6 +953,64 @@ declare class Aggregate {
|
|
|
1019
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>>;
|
|
1020
954
|
}
|
|
1021
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
|
+
|
|
1022
1014
|
declare type GetArg<T extends QueryBase> = keyof T['selectable'] | (RelationQueryBase & {
|
|
1023
1015
|
returnType: 'value' | 'valueOrThrow';
|
|
1024
1016
|
}) | RawExpression;
|
|
@@ -1034,6 +1026,79 @@ declare class QueryGet {
|
|
|
1034
1026
|
_getOptional<T extends Query, Arg extends GetArg<T>>(this: T, arg: Arg): GetOptionalResult<T, Arg>;
|
|
1035
1027
|
}
|
|
1036
1028
|
|
|
1029
|
+
declare type HavingArgObject<T extends Query, Agg extends keyof Aggregate1ArgumentTypes<T>> = {
|
|
1030
|
+
[Column in Exclude<Aggregate1ArgumentTypes<T>[Agg], RawExpression>]?: T['selectable'][Column]['column']['type'] | (ColumnOperators<T['selectable'], Column> & AggregateOptions<T>);
|
|
1031
|
+
};
|
|
1032
|
+
declare type HavingArg<T extends Query = Query> = ({
|
|
1033
|
+
[Agg in keyof Aggregate1ArgumentTypes<T>]?: HavingArgObject<T, Agg>;
|
|
1034
|
+
} & {
|
|
1035
|
+
count?: number | HavingArgObject<T, 'count'>;
|
|
1036
|
+
}) | Query | RawExpression;
|
|
1037
|
+
declare class Having {
|
|
1038
|
+
having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1039
|
+
_having<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1040
|
+
havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1041
|
+
_havingOr<T extends Query>(this: T, ...args: HavingArg<T>[]): T;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
declare type JsonColumnName<T extends Pick<Query, 'selectable'>> = StringKey<{
|
|
1045
|
+
[K in keyof T['selectable']]: T['selectable'][K]['column']['dataType'] extends 'jsonb' ? K : never;
|
|
1046
|
+
}[keyof T['selectable']]>;
|
|
1047
|
+
declare type ColumnOrJsonMethod<T extends Query> = JsonColumnName<T> | JsonItem;
|
|
1048
|
+
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);
|
|
1049
|
+
declare type JsonPathQueryResult<T extends Query, As extends string, Type extends ColumnType> = JsonItem & AddQuerySelect<T, {
|
|
1050
|
+
[K in As]: Type;
|
|
1051
|
+
}>;
|
|
1052
|
+
declare class Json {
|
|
1053
|
+
json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1054
|
+
_json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1055
|
+
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?: {
|
|
1056
|
+
as?: As;
|
|
1057
|
+
createIfMissing?: boolean;
|
|
1058
|
+
}): JsonSetResult<T, Column, As>;
|
|
1059
|
+
_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?: {
|
|
1060
|
+
as?: As;
|
|
1061
|
+
createIfMissing?: boolean;
|
|
1062
|
+
}): JsonSetResult<T, Column, As>;
|
|
1063
|
+
jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1064
|
+
column: Column,
|
|
1065
|
+
path: Array<string | number>,
|
|
1066
|
+
value: unknown,
|
|
1067
|
+
options?: {
|
|
1068
|
+
as?: As;
|
|
1069
|
+
insertAfter?: boolean;
|
|
1070
|
+
}
|
|
1071
|
+
]): JsonSetResult<T, Column, As>;
|
|
1072
|
+
_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?: {
|
|
1073
|
+
as?: As;
|
|
1074
|
+
insertAfter?: boolean;
|
|
1075
|
+
}): JsonSetResult<T, Column, As>;
|
|
1076
|
+
jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1077
|
+
column: Column,
|
|
1078
|
+
path: Array<string | number>,
|
|
1079
|
+
options?: {
|
|
1080
|
+
as?: As;
|
|
1081
|
+
}
|
|
1082
|
+
]): JsonSetResult<T, Column, As>;
|
|
1083
|
+
_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?: {
|
|
1084
|
+
as?: As;
|
|
1085
|
+
}): JsonSetResult<T, Column, As>;
|
|
1086
|
+
jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, ...args: [
|
|
1087
|
+
type: Type,
|
|
1088
|
+
column: ColumnOrJsonMethod<T>,
|
|
1089
|
+
path: string,
|
|
1090
|
+
as: As,
|
|
1091
|
+
options?: {
|
|
1092
|
+
vars?: string;
|
|
1093
|
+
silent?: boolean;
|
|
1094
|
+
}
|
|
1095
|
+
]): JsonPathQueryResult<T, As, Type>;
|
|
1096
|
+
_jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, type: Type, column: ColumnOrJsonMethod<T>, path: string, as: As, options?: {
|
|
1097
|
+
vars?: string;
|
|
1098
|
+
silent?: boolean;
|
|
1099
|
+
}): JsonPathQueryResult<T, As, Type>;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1037
1102
|
declare type SelectArg<T extends QueryBase> = keyof T['selectable'] | (T['relations'] extends Record<string, Relation> ? keyof T['relations'] : never) | RelationQueryBase | SelectAsArg<T>;
|
|
1038
1103
|
declare type SelectAsArg<T extends QueryBase> = Record<string, keyof T['selectable'] | Query | RawExpression>;
|
|
1039
1104
|
declare type SelectResult<T extends Query, Args extends SelectArg<T>[], SelectAsArgs = SimpleSpread<FilterTuple<Args, SelectAsArg<QueryBase>>>> = AddQuerySelect<T, {
|
|
@@ -1055,19 +1120,50 @@ declare class Select {
|
|
|
1055
1120
|
_selectAll<T extends Query>(this: T): QuerySelectAll<T>;
|
|
1056
1121
|
}
|
|
1057
1122
|
|
|
1058
|
-
declare type
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
declare
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1123
|
+
declare type ThenResult<Res> = (resolve?: (value: Res) => any, reject?: (error: any) => any) => Promise<Res | never>;
|
|
1124
|
+
declare const queryMethodByReturnType: Record<QueryReturnType, 'query' | 'arrays'>;
|
|
1125
|
+
declare class Then {
|
|
1126
|
+
then(this: Query, resolve?: (result: any) => any, reject?: (error: any) => any): Promise<any>;
|
|
1127
|
+
}
|
|
1128
|
+
declare const handleResult: CommonQueryData['handleResult'];
|
|
1129
|
+
declare const parseResult: (q: Query, returnType: QueryReturnType, result: QueryResult) => unknown;
|
|
1130
|
+
declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
|
|
1131
|
+
|
|
1132
|
+
declare class Transaction {
|
|
1133
|
+
transaction<T extends Query, Result>(this: T, cb: (query: T) => Promise<Result>): Promise<Result>;
|
|
1134
|
+
transacting<T extends Query>(this: T, query: Query): T;
|
|
1135
|
+
_transacting<T extends Query>(this: T, query: Query): T;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
declare type UnionArg<T extends Query> = (Omit<Query, 'result'> & {
|
|
1139
|
+
result: T['result'];
|
|
1140
|
+
}) | RawExpression;
|
|
1141
|
+
declare class Union {
|
|
1142
|
+
union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1143
|
+
_union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1144
|
+
unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1145
|
+
_unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1146
|
+
intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1147
|
+
_intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1148
|
+
intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1149
|
+
_intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1150
|
+
except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1151
|
+
_except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1152
|
+
exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1153
|
+
_exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
declare type UpsertData<T extends Query> = {
|
|
1157
|
+
update: UpdateData<T>;
|
|
1158
|
+
create: InsertData<T>;
|
|
1159
|
+
};
|
|
1160
|
+
declare type UpsertResult<T extends Query> = T['hasSelect'] extends true ? SetQueryReturnsOne<T> : SetQueryReturnsVoid<T>;
|
|
1161
|
+
declare type UpsertThis = WhereResult<Query> & {
|
|
1162
|
+
returnType: 'one' | 'oneOrThrow';
|
|
1163
|
+
};
|
|
1164
|
+
declare class QueryUpsert {
|
|
1165
|
+
upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
1166
|
+
_upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
1071
1167
|
}
|
|
1072
1168
|
|
|
1073
1169
|
declare type DbTableOptions = {
|
|
@@ -1240,145 +1336,69 @@ declare class With {
|
|
|
1240
1336
|
_with<T extends Query, Args extends WithArgs, Shape extends ColumnsShape = WithShape<Args>>(this: T, ...args: Args): WithResult<T, Args, Shape>;
|
|
1241
1337
|
}
|
|
1242
1338
|
|
|
1243
|
-
declare type
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
_union<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1249
|
-
unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1250
|
-
_unionAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1251
|
-
intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1252
|
-
_intersect<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1253
|
-
intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1254
|
-
_intersectAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1255
|
-
except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1256
|
-
_except<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1257
|
-
exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1258
|
-
_exceptAll<T extends Query>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
declare type JsonColumnName<T extends Pick<Query, 'selectable'>> = StringKey<{
|
|
1262
|
-
[K in keyof T['selectable']]: T['selectable'][K]['column']['dataType'] extends 'jsonb' ? K : never;
|
|
1263
|
-
}[keyof T['selectable']]>;
|
|
1264
|
-
declare type ColumnOrJsonMethod<T extends Query> = JsonColumnName<T> | JsonItem;
|
|
1265
|
-
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);
|
|
1266
|
-
declare type JsonPathQueryResult<T extends Query, As extends string, Type extends ColumnType> = JsonItem & AddQuerySelect<T, {
|
|
1267
|
-
[K in As]: Type;
|
|
1268
|
-
}>;
|
|
1269
|
-
declare class Json {
|
|
1270
|
-
json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1271
|
-
_json<T extends Query>(this: T): SetQueryReturnsValueOptional<T, StringColumn>;
|
|
1272
|
-
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?: {
|
|
1273
|
-
as?: As;
|
|
1274
|
-
createIfMissing?: boolean;
|
|
1275
|
-
}): JsonSetResult<T, Column, As>;
|
|
1276
|
-
_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?: {
|
|
1277
|
-
as?: As;
|
|
1278
|
-
createIfMissing?: boolean;
|
|
1279
|
-
}): JsonSetResult<T, Column, As>;
|
|
1280
|
-
jsonInsert<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1281
|
-
column: Column,
|
|
1282
|
-
path: Array<string | number>,
|
|
1283
|
-
value: unknown,
|
|
1284
|
-
options?: {
|
|
1285
|
-
as?: As;
|
|
1286
|
-
insertAfter?: boolean;
|
|
1287
|
-
}
|
|
1288
|
-
]): JsonSetResult<T, Column, As>;
|
|
1289
|
-
_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?: {
|
|
1290
|
-
as?: As;
|
|
1291
|
-
insertAfter?: boolean;
|
|
1292
|
-
}): JsonSetResult<T, Column, As>;
|
|
1293
|
-
jsonRemove<T extends Query, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, ...args: [
|
|
1294
|
-
column: Column,
|
|
1295
|
-
path: Array<string | number>,
|
|
1296
|
-
options?: {
|
|
1297
|
-
as?: As;
|
|
1298
|
-
}
|
|
1299
|
-
]): JsonSetResult<T, Column, As>;
|
|
1300
|
-
_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?: {
|
|
1301
|
-
as?: As;
|
|
1302
|
-
}): JsonSetResult<T, Column, As>;
|
|
1303
|
-
jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, ...args: [
|
|
1304
|
-
type: Type,
|
|
1305
|
-
column: ColumnOrJsonMethod<T>,
|
|
1306
|
-
path: string,
|
|
1307
|
-
as: As,
|
|
1308
|
-
options?: {
|
|
1309
|
-
vars?: string;
|
|
1310
|
-
silent?: boolean;
|
|
1311
|
-
}
|
|
1312
|
-
]): JsonPathQueryResult<T, As, Type>;
|
|
1313
|
-
_jsonPathQuery<T extends Query, As extends string, Type extends ColumnType>(this: T, type: Type, column: ColumnOrJsonMethod<T>, path: string, as: As, options?: {
|
|
1314
|
-
vars?: string;
|
|
1315
|
-
silent?: boolean;
|
|
1316
|
-
}): JsonPathQueryResult<T, As, Type>;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
declare type DeleteArgs<T extends Query> = T['hasWhere'] extends true ? [forceAll?: boolean] : [true];
|
|
1320
|
-
declare type DeleteResult<T extends Query> = T['hasSelect'] extends false ? SetQueryReturnsRowCount<T> : T;
|
|
1321
|
-
declare class Delete {
|
|
1322
|
-
del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
1323
|
-
_del<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
1324
|
-
delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
1325
|
-
_delete<T extends Query>(this: T, ...args: DeleteArgs<T>): DeleteResult<T>;
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
declare class Transaction {
|
|
1329
|
-
transaction<T extends Query, Result>(this: T, cb: (query: T) => Promise<Result>): Promise<Result>;
|
|
1330
|
-
transacting<T extends Query>(this: T, query: Query): T;
|
|
1331
|
-
_transacting<T extends Query>(this: T, query: Query): T;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
declare type ForQueryBuilder<Q extends Query> = Q & {
|
|
1335
|
-
noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
1336
|
-
_noWait<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
1337
|
-
skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
1338
|
-
_skipLocked<T extends ForQueryBuilder<Q>>(this: T): T;
|
|
1339
|
+
declare type ToSqlCtx = {
|
|
1340
|
+
whereQueryBuilder: typeof WhereQueryBuilder;
|
|
1341
|
+
onQueryBuilder: typeof OnQueryBuilder;
|
|
1342
|
+
sql: string[];
|
|
1343
|
+
values: unknown[];
|
|
1339
1344
|
};
|
|
1340
|
-
declare
|
|
1341
|
-
forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1342
|
-
_forUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1343
|
-
forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1344
|
-
_forNoKeyUpdate<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1345
|
-
forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1346
|
-
_forShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1347
|
-
forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1348
|
-
_forKeyShare<T extends Query>(this: T, tableNames?: string[] | RawExpression): ForQueryBuilder<T>;
|
|
1349
|
-
}
|
|
1345
|
+
declare const toSql: (model: Query, values?: unknown[]) => Sql;
|
|
1350
1346
|
|
|
1351
|
-
declare type
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
maxLength: number | null;
|
|
1355
|
-
nullable: boolean;
|
|
1347
|
+
declare type MaybeArray<T> = T | T[];
|
|
1348
|
+
declare type SetOptional<T, K extends PropertyKey> = Omit<T, K> & {
|
|
1349
|
+
[P in K]?: P extends keyof T ? T[P] : never;
|
|
1356
1350
|
};
|
|
1357
|
-
declare
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
declare type
|
|
1363
|
-
declare
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1351
|
+
declare type GetTypesOrRaw<T extends [...unknown[]]> = T extends [
|
|
1352
|
+
infer Head,
|
|
1353
|
+
...infer Tail
|
|
1354
|
+
] ? [GetTypeOrRaw<Head>, ...GetTypesOrRaw<Tail>] : [];
|
|
1355
|
+
declare type GetTypeOrRaw<T> = T | RawExpression;
|
|
1356
|
+
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
1357
|
+
declare type UnionToOvlds<U> = UnionToIntersection<U extends any ? (f: U) => void : never>;
|
|
1358
|
+
declare type PopPropertyKeyUnion<U> = UnionToOvlds<U> extends (a: infer A extends PropertyKey) => void ? A : never;
|
|
1359
|
+
declare type IsUnion$1<T> = [T] extends [UnionToIntersection<T>] ? false : true;
|
|
1360
|
+
declare type PropertyKeyUnionToArray<T, A extends PropertyKey[] = []> = IsUnion$1<T> extends true ? PropertyKeyUnionToArray<Exclude<T, PopPropertyKeyUnion<T>>, [
|
|
1361
|
+
PopPropertyKeyUnion<T>,
|
|
1362
|
+
...A
|
|
1363
|
+
]> : [T, ...A];
|
|
1364
|
+
declare type OptionalPropertyNames<T> = {
|
|
1365
|
+
[K in keyof T]-?: {} extends {
|
|
1366
|
+
[P in K]: T[K];
|
|
1367
|
+
} ? K : never;
|
|
1368
|
+
}[keyof T];
|
|
1369
|
+
declare type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
1370
|
+
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
1370
1371
|
};
|
|
1371
|
-
declare type
|
|
1372
|
-
[
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1372
|
+
declare type Id<T> = T extends infer U ? {
|
|
1373
|
+
[K in keyof U]: U[K];
|
|
1374
|
+
} : never;
|
|
1375
|
+
declare type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
1376
|
+
declare type Spread<A extends readonly [...any]> = A extends [
|
|
1377
|
+
infer L,
|
|
1378
|
+
...infer R
|
|
1379
|
+
] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
1380
|
+
declare type SimpleSpread<A extends readonly [...any]> = A extends [
|
|
1381
|
+
infer L,
|
|
1382
|
+
...infer R
|
|
1383
|
+
] ? L & SimpleSpread<R> : {};
|
|
1384
|
+
declare type FilterTuple<T extends readonly any[], E> = T extends [
|
|
1385
|
+
infer F,
|
|
1386
|
+
...infer R
|
|
1387
|
+
] ? [F] extends [E] ? [F, ...FilterTuple<R, E>] : FilterTuple<R, E> : [];
|
|
1388
|
+
declare type CoalesceString<Left extends string | undefined, Right extends string> = Left extends undefined ? Right : Left;
|
|
1389
|
+
declare function applyMixins(derivedCtor: any, constructors: any[]): void;
|
|
1390
|
+
declare const joinTruthy: (...strings: (string | false | undefined)[]) => string;
|
|
1391
|
+
declare const getClonedQueryData: (query: QueryData) => QueryData;
|
|
1392
|
+
declare const getQueryAs: (q: {
|
|
1393
|
+
table?: string;
|
|
1394
|
+
query: {
|
|
1395
|
+
as?: string;
|
|
1396
|
+
};
|
|
1397
|
+
}) => string;
|
|
1398
|
+
declare const toArray: <T>(item: T) => T extends unknown[] ? T : [T];
|
|
1399
|
+
declare const noop: () => void;
|
|
1400
|
+
declare type EmptyObject = typeof emptyObject;
|
|
1401
|
+
declare const emptyObject: {};
|
|
1382
1402
|
|
|
1383
1403
|
declare class Window {
|
|
1384
1404
|
selectRowNumber<T extends Query, As extends string | undefined = undefined>(this: T, options: WindowFunctionOptions<T, As>): SelectAgg<T, 'row_number', As, IntegerColumn>;
|
|
@@ -1393,19 +1413,6 @@ declare class Window {
|
|
|
1393
1413
|
_selectCumeDist<T extends Query, As extends string | undefined = undefined>(this: T, options: WindowFunctionOptions<T, As>): SelectAgg<T, 'cume_dist', As, IntegerColumn>;
|
|
1394
1414
|
}
|
|
1395
1415
|
|
|
1396
|
-
declare type UpsertData<T extends Query> = {
|
|
1397
|
-
update: UpdateData<T>;
|
|
1398
|
-
create: InsertData<T>;
|
|
1399
|
-
};
|
|
1400
|
-
declare type UpsertResult<T extends Query> = T['hasSelect'] extends true ? SetQueryReturnsOne<T> : SetQueryReturnsVoid<T>;
|
|
1401
|
-
declare type UpsertThis = WhereResult<Query> & {
|
|
1402
|
-
returnType: 'one' | 'oneOrThrow';
|
|
1403
|
-
};
|
|
1404
|
-
declare class QueryUpsert {
|
|
1405
|
-
upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
1406
|
-
_upsert<T extends UpsertThis>(this: T, data: UpsertData<T>): UpsertResult<T>;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
1416
|
declare type WindowArg<T extends Query> = Record<string, WindowArgDeclaration<T> | RawExpression>;
|
|
1410
1417
|
declare type WindowArgDeclaration<T extends Query = Query> = {
|
|
1411
1418
|
partitionBy?: Expression<T> | Expression<T>[];
|
|
@@ -1463,8 +1470,8 @@ declare class QueryMethods {
|
|
|
1463
1470
|
_limit<T extends Query>(this: T, arg: number | undefined): T;
|
|
1464
1471
|
offset<T extends Query>(this: T, arg: number | undefined): T;
|
|
1465
1472
|
_offset<T extends Query>(this: T, arg: number | undefined): T;
|
|
1466
|
-
exists<T extends Query>(this: T):
|
|
1467
|
-
_exists<T extends Query>(this: T):
|
|
1473
|
+
exists<T extends Query>(this: T): SetQueryReturnsValue<T, BooleanColumn>;
|
|
1474
|
+
_exists<T extends Query>(this: T): SetQueryReturnsValue<T, BooleanColumn>;
|
|
1468
1475
|
truncate<T extends Query>(this: T, options?: {
|
|
1469
1476
|
restartIdentity?: boolean;
|
|
1470
1477
|
cascade?: boolean;
|
|
@@ -1492,6 +1499,7 @@ declare type QueryBase = {
|
|
|
1492
1499
|
tableAlias?: string;
|
|
1493
1500
|
clone(): QueryBase;
|
|
1494
1501
|
selectable: SelectableBase;
|
|
1502
|
+
shape: ColumnsShape;
|
|
1495
1503
|
__model: Query;
|
|
1496
1504
|
relations: RelationsBase;
|
|
1497
1505
|
withData: WithDataBase;
|
|
@@ -4296,4 +4304,4 @@ declare class UnhandledTypeError extends PormInternalError {
|
|
|
4296
4304
|
constructor(value: never);
|
|
4297
4305
|
}
|
|
4298
4306
|
|
|
4299
|
-
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, OptionalKeys, 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, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TableSchema, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, 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 };
|
|
4307
|
+
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, OptionalKeys, 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, 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 };
|