pqb 0.68.1 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +245 -212
- package/dist/index.js +587 -545
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +587 -545
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +238 -206
- package/dist/node-postgres.js +9 -15
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs +9 -15
- package/dist/node-postgres.mjs.map +1 -1
- package/dist/postgres-js.js +64 -0
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs +64 -0
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1776,6 +1776,8 @@ declare class BooleanColumn<Schema extends ColumnSchemaConfig> extends Column {
|
|
|
1776
1776
|
querySchema: ReturnType<Schema['boolean']>;
|
|
1777
1777
|
private static _instance;
|
|
1778
1778
|
static get instance(): BooleanColumn<DefaultSchemaConfig>;
|
|
1779
|
+
private static _instanceSkipValueToArray;
|
|
1780
|
+
static get instanceSkipValueToArray(): BooleanColumn<DefaultSchemaConfig>;
|
|
1779
1781
|
constructor(schema: Schema);
|
|
1780
1782
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
|
1781
1783
|
}
|
|
@@ -1959,21 +1961,23 @@ interface JoinItem {
|
|
|
1959
1961
|
type: string;
|
|
1960
1962
|
args: JoinItemArgs;
|
|
1961
1963
|
}
|
|
1962
|
-
type getValueKey = typeof getValueKey;
|
|
1963
|
-
declare const getValueKey: unique symbol;
|
|
1964
1964
|
interface PickQueryDataParsers {
|
|
1965
1965
|
defaultParsers?: ColumnsParsers;
|
|
1966
1966
|
parsers?: ColumnsParsers;
|
|
1967
1967
|
batchParsers?: BatchParsers;
|
|
1968
1968
|
}
|
|
1969
1969
|
type ColumnParser = FnUnknownToUnknown;
|
|
1970
|
+
interface BatchParserPathEntry {
|
|
1971
|
+
key: string;
|
|
1972
|
+
returnType: QueryReturnType;
|
|
1973
|
+
}
|
|
1970
1974
|
interface BatchParser {
|
|
1971
|
-
path:
|
|
1972
|
-
fn: (path:
|
|
1975
|
+
path: BatchParserPathEntry[];
|
|
1976
|
+
fn: (path: BatchParserPathEntry[], queryResult: {
|
|
1973
1977
|
rows: unknown[];
|
|
1974
1978
|
}) => MaybePromise<void>;
|
|
1975
1979
|
}
|
|
1976
|
-
type ColumnsParsers = { [K in string
|
|
1980
|
+
type ColumnsParsers = { [K in string]?: ColumnParser };
|
|
1977
1981
|
type BatchParsers = BatchParser[];
|
|
1978
1982
|
interface QueryThen<T> {
|
|
1979
1983
|
<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
|
|
@@ -2105,12 +2109,6 @@ interface JoinCallback<T extends PickQuerySelectableShapeRelationsWithDataAs, Ar
|
|
|
2105
2109
|
(q: JoinQueryBuilder<T, JoinArgToQuery<T, Arg>>): IsQuery;
|
|
2106
2110
|
}
|
|
2107
2111
|
type JoinCallbackArgs<T extends PickQuerySelectableShapeRelationsWithDataAs, Arg extends JoinFirstArg<T>> = [cb?: JoinCallback<T, Arg> | true];
|
|
2108
|
-
/**
|
|
2109
|
-
* Type of {@link QueryJoin.join} query method.
|
|
2110
|
-
*/
|
|
2111
|
-
interface JoinQueryMethod {
|
|
2112
|
-
<T extends PickQuerySelectableResultRelationsWithDataReturnTypeShapeAs, Arg extends JoinFirstArg<T>, Cb extends JoinCallbackArgs<T, Arg>>(this: T, arg: Arg, ...args: Cb | JoinArgs<T, Arg>): JoinResultFromArgs<T, Arg, Cb, true, true>;
|
|
2113
|
-
}
|
|
2114
2112
|
declare class QueryJoin {
|
|
2115
2113
|
/**
|
|
2116
2114
|
* ## Select relation
|
|
@@ -2977,172 +2975,6 @@ interface AggregateOptions<T extends PickQuerySelectableResultRelationsWindows>
|
|
|
2977
2975
|
over?: Over<T>;
|
|
2978
2976
|
}
|
|
2979
2977
|
type Over<T extends PickQuerySelectableResultWindows> = keyof T['windows'] | WindowArgDeclaration<T>;
|
|
2980
|
-
interface ColumnsShape {
|
|
2981
|
-
[K: string]: Column;
|
|
2982
|
-
}
|
|
2983
|
-
declare namespace ColumnsShape {
|
|
2984
|
-
export type DefaultSelectKeys<S extends Column.QueryColumnsInit> = { [K in keyof S]: S[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof S];
|
|
2985
|
-
export type DefaultOutput<Set extends Column.QueryColumnsInit> = { [K in DefaultSelectKeys<Set>]: Set[K]['__outputType'] };
|
|
2986
|
-
export type Input<Shape extends Column.QueryColumnsInit, AppReadOnly = { [K in keyof Shape]: Shape[K]['data']['appReadOnly'] extends true ? K : never }[keyof Shape], Optional extends keyof Shape = { [K in keyof Shape]: Shape[K]['data']['optional'] extends true ? K : never }[keyof Shape]> = { [K in Exclude<keyof Shape, AppReadOnly | Optional>]: Shape[K]['__inputType'] } & { [K in Exclude<Optional, AppReadOnly>]?: Shape[K]['__inputType'] };
|
|
2987
|
-
export type InputPartial<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]?: Shape[K]['__inputType'] };
|
|
2988
|
-
export type Output<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
|
|
2989
|
-
export type DefaultSelectOutput<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof Shape]]: Shape[K]['__outputType'] };
|
|
2990
|
-
export interface MapToObjectColumn<Shape extends Column.QueryColumns> {
|
|
2991
|
-
dataType: 'object';
|
|
2992
|
-
__type: { [K in keyof Shape]: Shape[K]['__type'] };
|
|
2993
|
-
__outputType: ShallowSimplify<ObjectOutput<Shape>>;
|
|
2994
|
-
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] };
|
|
2995
|
-
operators: OperatorsAny;
|
|
2996
|
-
}
|
|
2997
|
-
export interface MapToNullableObjectColumn<Shape extends Column.QueryColumns> {
|
|
2998
|
-
dataType: 'object';
|
|
2999
|
-
__type: { [K in keyof Shape]: Shape[K]['__type'] };
|
|
3000
|
-
__outputType: ShallowSimplify<ObjectOutput<Shape>> | undefined;
|
|
3001
|
-
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] } | null;
|
|
3002
|
-
operators: OperatorsAny;
|
|
3003
|
-
}
|
|
3004
|
-
export interface MapToPluckColumn<Shape extends Column.QueryColumns> {
|
|
3005
|
-
dataType: 'array';
|
|
3006
|
-
__type: Shape['pluck']['__type'][];
|
|
3007
|
-
__outputType: Shape['pluck']['__outputType'][];
|
|
3008
|
-
__queryType: Shape['pluck']['__queryType'][];
|
|
3009
|
-
operators: OperatorsAny;
|
|
3010
|
-
}
|
|
3011
|
-
export interface MapToObjectArrayColumn<Shape extends Column.QueryColumns> {
|
|
3012
|
-
dataType: 'array';
|
|
3013
|
-
__type: { [K in keyof Shape]: Shape[K]['__type'] }[];
|
|
3014
|
-
__outputType: ShallowSimplify<ObjectOutput<Shape>>[];
|
|
3015
|
-
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] }[];
|
|
3016
|
-
operators: OperatorsAny;
|
|
3017
|
-
}
|
|
3018
|
-
type ObjectOutput<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
|
|
3019
|
-
export {};
|
|
3020
|
-
}
|
|
3021
|
-
interface SelectSelf extends PickQuerySelectable, PickQueryHasSelect, PickQueryDefaultSelect, PickQueryShape, PickQueryRelations, PickQueryResult, PickQueryReturnType, PickQueryWithData {}
|
|
3022
|
-
type SelectArgs<T extends SelectSelf> = ('*' | keyof T['__selectable'])[];
|
|
3023
|
-
interface SubQueryAddition<T extends PickQueryWithData> extends IsSubQuery {
|
|
3024
|
-
withData: T['withData'];
|
|
3025
|
-
}
|
|
3026
|
-
type SelectAsFnArg<T extends PickQueryRelationsWithData> = EmptyObject extends T['relations'] ? T : { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? RelationQueryMaybeSingle<T['relations'][K]> & SubQueryAddition<T> : K extends keyof T ? T[K] : never };
|
|
3027
|
-
interface SelectAsArg<T extends SelectSelf> {
|
|
3028
|
-
[K: string]: keyof T['__selectable'] | Expression | ((q: SelectAsFnArg<T>) => unknown);
|
|
3029
|
-
}
|
|
3030
|
-
type SelectAsFnReturnType = {
|
|
3031
|
-
result: Column.QueryColumns;
|
|
3032
|
-
returnType: Exclude<QueryReturnType, 'rows'>;
|
|
3033
|
-
} | Expression;
|
|
3034
|
-
interface SelectAsCheckReturnTypes {
|
|
3035
|
-
[K: string]: PropertyKey | Expression | ((q: never) => SelectAsFnReturnType);
|
|
3036
|
-
}
|
|
3037
|
-
type SelectReturnType<T extends PickQueryReturnType> = T['returnType'] extends 'valueOrThrow' ? 'oneOrThrow' : T extends 'value' ? 'one' : T['returnType'] extends 'pluck' ? 'all' : T['returnType'];
|
|
3038
|
-
type SelectResult<T extends SelectSelf, Columns extends PropertyKey[]> = { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? { [K in '*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number] as T['__selectable'][K]['as']]: T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown) : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in '*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number] as T['__selectable'][K]['as']]: T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown)> : T[K] };
|
|
3039
|
-
type SelectResultObj<T extends SelectSelf, Obj> = Obj extends SelectAsCheckReturnTypes ? { [K in keyof T]: K extends '__hasSelect' ? true : K extends '__selectable' ? T['__selectable'] & SelectAsSelectable<Obj> : K extends 'result' ? { [K in T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? keyof Obj | keyof T['result'] : keyof Obj]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : K extends keyof T['result'] ? T['result'][K] : never } : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? keyof Obj | keyof T['result'] : keyof Obj]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : K extends keyof T['result'] ? T['result'][K] : never }> : T[K] } : `Invalid return type of ${{ [K in keyof Obj]: Obj[K] extends ((...args: any[]) => any) ? ReturnType<Obj[K]> extends SelectAsFnReturnType ? never : K : never }[keyof Obj] & string}`;
|
|
3040
|
-
type SelectResultColumnsAndObj<T extends SelectSelf, Columns extends PropertyKey[], Obj> = { [K in keyof T]: K extends '__hasSelect' ? true : K extends '__selectable' ? T['__selectable'] & SelectAsSelectable<Obj> : K extends 'result' ? // Combine previously selected items, all columns if * was provided,
|
|
3041
|
-
{ [K in ('*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number]) | keyof Obj as K extends Columns[number] ? T['__selectable'][K]['as'] : K]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown) : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in ('*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number]) | keyof Obj as K extends Columns[number] ? T['__selectable'][K]['as'] : K]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown)> : T[K] };
|
|
3042
|
-
interface AllowedRelationOneQueryForSelectable extends IsSubQuery {
|
|
3043
|
-
result: Column.QueryColumns;
|
|
3044
|
-
returnType: 'value' | 'valueOrThrow' | 'one' | 'oneOrThrow';
|
|
3045
|
-
}
|
|
3046
|
-
type SelectAsSelectable<Obj> = UnionToIntersection<{ [K in keyof Obj]: Obj[K] extends ((q: never) => infer R extends AllowedRelationOneQueryForSelectable) ? { [C in R['returnType'] extends 'value' | 'valueOrThrow' ? K : keyof R['result'] as R['returnType'] extends 'value' | 'valueOrThrow' ? K : `${K & string}.${C & string}`]: {
|
|
3047
|
-
as: C;
|
|
3048
|
-
column: R['returnType'] extends 'value' | 'valueOrThrow' ? R['result']['value'] : R['result'][C & keyof R['result']];
|
|
3049
|
-
} } : never }[keyof Obj]>;
|
|
3050
|
-
type SelectAsValueResult<T extends SelectSelf, Arg> = Arg extends keyof T['__selectable'] ? T['__selectable'][Arg]['column'] : Arg extends Expression ? Arg['result']['value'] : Arg extends ((q: never) => IsQuery) ? SelectSubQueryResult<ReturnType<Arg>> : Arg extends ((q: never) => Expression) ? ReturnType<Arg>['result']['value'] : Arg extends ((q: never) => IsQuery | Expression) ? SelectSubQueryResult<Exclude<ReturnType<Arg>, Expression>> | Exclude<ReturnType<Arg>, IsQuery>['result']['value'] : never;
|
|
3051
|
-
type SelectSubQueryResult<Arg extends SelectSelf> = Arg['returnType'] extends undefined | 'all' ? ColumnsShape.MapToObjectArrayColumn<Arg['result']> : Arg['returnType'] extends 'value' | 'valueOrThrow' ? Arg['result']['value'] : Arg['returnType'] extends 'pluck' ? ColumnsShape.MapToPluckColumn<Arg['result']> : Arg['returnType'] extends 'one' ? ColumnsShape.MapToNullableObjectColumn<Arg['result']> : ColumnsShape.MapToObjectColumn<Arg['result']>;
|
|
3052
|
-
declare function _querySelect<T extends SelectSelf, Columns extends SelectArgs<T>>(q: T, columns: Columns): SelectResult<T, Columns>;
|
|
3053
|
-
declare function _querySelect<T extends SelectSelf, Obj extends SelectAsArg<T>>(q: T, obj: Obj): SelectResultObj<T, Obj>;
|
|
3054
|
-
declare function _querySelect<T extends SelectSelf, Columns extends SelectArgs<T>, Obj extends SelectAsArg<T>>(q: T, args: [...columns: Columns, obj: Obj]): SelectResultColumnsAndObj<T, Columns, Obj>;
|
|
3055
|
-
declare class Select {
|
|
3056
|
-
/**
|
|
3057
|
-
* Takes a list of columns to be selected, and by default, the query builder will select all columns of the table.
|
|
3058
|
-
*
|
|
3059
|
-
* The last argument can be an object. Keys of the object are column aliases, value can be a column name, sub-query, or raw SQL expression.
|
|
3060
|
-
*
|
|
3061
|
-
* ```ts
|
|
3062
|
-
* import { sql } from './baseTable'
|
|
3063
|
-
*
|
|
3064
|
-
* // select columns of the table:
|
|
3065
|
-
* db.table.select('id', 'name', { idAlias: 'id' });
|
|
3066
|
-
*
|
|
3067
|
-
* // accepts columns with table names:
|
|
3068
|
-
* db.table.select('user.id', 'user.name', { nameAlias: 'user.name' });
|
|
3069
|
-
*
|
|
3070
|
-
* // table name may refer to the current table or a joined table:
|
|
3071
|
-
* db.table
|
|
3072
|
-
* .join(db.message, 'authorId', 'user.id')
|
|
3073
|
-
* .select('user.name', 'message.text', { textAlias: 'message.text' });
|
|
3074
|
-
*
|
|
3075
|
-
* // select value from the sub-query,
|
|
3076
|
-
* // this sub-query should return a single record and a single column:
|
|
3077
|
-
* db.table.select({
|
|
3078
|
-
* subQueryResult: Otherdb.table.select('column').take(),
|
|
3079
|
-
* });
|
|
3080
|
-
*
|
|
3081
|
-
* // select raw SQL value, specify the returning type via <generic> syntax:
|
|
3082
|
-
* db.table.select({
|
|
3083
|
-
* raw: sql<number>`1 + 2`,
|
|
3084
|
-
* });
|
|
3085
|
-
*
|
|
3086
|
-
* // select raw SQL value, the resulting type can be set by providing a column type in such way:
|
|
3087
|
-
* db.table.select({
|
|
3088
|
-
* raw: sql`1 + 2`.type((t) => t.integer()),
|
|
3089
|
-
* });
|
|
3090
|
-
*
|
|
3091
|
-
* // same raw SQL query as above, but the sql is returned from a callback
|
|
3092
|
-
* db.table.select({
|
|
3093
|
-
* raw: () => sql`1 + 2`.type((t) => t.integer()),
|
|
3094
|
-
* });
|
|
3095
|
-
* ```
|
|
3096
|
-
*
|
|
3097
|
-
* When you use the ORM and defined relations, `select` can also accept callbacks with related table queries:
|
|
3098
|
-
*
|
|
3099
|
-
* ```ts
|
|
3100
|
-
* await db.author.select({
|
|
3101
|
-
* allBooks: (q) => q.books,
|
|
3102
|
-
* firstBook: (q) => q.books.order({ createdAt: 'ASC' }).take(),
|
|
3103
|
-
* booksCount: (q) => q.books.count(),
|
|
3104
|
-
* });
|
|
3105
|
-
* ```
|
|
3106
|
-
*
|
|
3107
|
-
* When you're selecting a relation that's connected via `belongsTo` or `hasOne`, it becomes available to use in `order` or in `where`:
|
|
3108
|
-
*
|
|
3109
|
-
* ```ts
|
|
3110
|
-
* // select books with their authors included, order by author name and filter by author column:
|
|
3111
|
-
* await db.books
|
|
3112
|
-
* .select({
|
|
3113
|
-
* author: (q) => q.author,
|
|
3114
|
-
* })
|
|
3115
|
-
* .order('author.name')
|
|
3116
|
-
* .where({ 'author.isPopular': true });
|
|
3117
|
-
* ```
|
|
3118
|
-
*/
|
|
3119
|
-
select<T extends SelectSelf, Columns extends SelectArgs<T>>(this: T, ...args: Columns): SelectResult<T, Columns>;
|
|
3120
|
-
select<T extends SelectSelf, Obj extends SelectAsArg<T>>(this: T, obj: Obj): SelectResultObj<T, Obj>;
|
|
3121
|
-
select<T extends SelectSelf, Columns extends SelectArgs<T>, Obj extends SelectAsArg<T>>(this: T, ...args: [...columns: Columns, obj: Obj]): SelectResultColumnsAndObj<T, Columns, Obj>;
|
|
3122
|
-
/**
|
|
3123
|
-
* When querying the table or creating records, all columns are selected by default,
|
|
3124
|
-
* but updating and deleting queries are returning affected row counts by default.
|
|
3125
|
-
*
|
|
3126
|
-
* Use `selectAll` to select all columns. If the `.select` method was applied before it will be discarded.
|
|
3127
|
-
*
|
|
3128
|
-
* ```ts
|
|
3129
|
-
* const selectFull = await db.table
|
|
3130
|
-
* .select('id', 'name') // discarded by `selectAll`
|
|
3131
|
-
* .selectAll();
|
|
3132
|
-
*
|
|
3133
|
-
* const updatedFull = await db.table.selectAll().where(conditions).update(data);
|
|
3134
|
-
*
|
|
3135
|
-
* const deletedFull = await db.table.selectAll().where(conditions).delete();
|
|
3136
|
-
* ```
|
|
3137
|
-
*/
|
|
3138
|
-
selectAll<T extends SelectSelf>(this: T): SelectResult<T, ['*']>;
|
|
3139
|
-
}
|
|
3140
|
-
interface QueryGetSelf extends PickQuerySelectable, PickQueryRelationsWithData {}
|
|
3141
|
-
type GetArg<T extends QueryGetSelf> = GetStringArg<T> | Expression | ((q: SelectAsFnArg<T>) => Expression | Query.Pick.SingleValueResult);
|
|
3142
|
-
type GetStringArg<T extends PickQuerySelectable> = keyof T['__selectable'] & string;
|
|
3143
|
-
type ResolveGetArgColumn<Arg> = Arg extends Expression ? Arg['result']['value'] : Arg extends ((q: never) => infer R) ? R extends Expression ? R['result']['value'] : R extends Query.Pick.SingleValueResult ? R['result']['value'] : never : never;
|
|
3144
|
-
type GetResult<T extends QueryGetSelf, Arg extends GetArg<T>> = Arg extends string ? SetQueryReturnsValueOrThrow<T, Arg> : SetQueryReturnsColumnOrThrow<T, ResolveGetArgColumn<Arg>>;
|
|
3145
|
-
type GetResultOptional<T extends QueryGetSelf, Arg extends GetArg<T>> = Arg extends string ? SetQueryReturnsValueOptional<T, Arg> : SetQueryReturnsColumnOptional<T, ResolveGetArgColumn<Arg>>;
|
|
3146
2978
|
type HeadlineSearchArg<T extends PickQueryTsQuery> = Exclude<T['__tsQuery'], undefined>;
|
|
3147
2979
|
interface HeadlineParams<T extends PickQuerySelectable> {
|
|
3148
2980
|
text?: SelectableOrExpressionOfType<T, Column.Pick.QueryColumnOfType<string>>;
|
|
@@ -3479,16 +3311,6 @@ interface AggregateArgTypes {
|
|
|
3479
3311
|
}
|
|
3480
3312
|
interface AggregateMethods extends SearchAggregateMethods {}
|
|
3481
3313
|
declare class AggregateMethods {
|
|
3482
|
-
/**
|
|
3483
|
-
* Use `exists()` to check if there is at least one record-matching condition.
|
|
3484
|
-
*
|
|
3485
|
-
* It will discard previous `select` statements if any. Returns a boolean.
|
|
3486
|
-
*
|
|
3487
|
-
* ```ts
|
|
3488
|
-
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
3489
|
-
* ```
|
|
3490
|
-
*/
|
|
3491
|
-
exists<T extends QueryGetSelf>(this: T): SetQueryReturnsColumnOrThrow<T, BooleanQueryColumn>;
|
|
3492
3314
|
/**
|
|
3493
3315
|
* Count records with the `count` function:
|
|
3494
3316
|
*
|
|
@@ -5139,7 +4961,8 @@ interface QueryInternal<SinglePrimaryKey = any, UniqueColumns = any, UniqueColum
|
|
|
5139
4961
|
*/
|
|
5140
4962
|
nestedCreateBatchMax: number;
|
|
5141
4963
|
}
|
|
5142
|
-
type
|
|
4964
|
+
type ShapeHasPrimaryKeys<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? K : never }[keyof Shape];
|
|
4965
|
+
type TablePrimaryKeys<Shape extends Column.QueryColumnsInit> = ShapeHasPrimaryKeys<Shape> extends never ? never : { [K in ShapeHasPrimaryKeys<Shape>]: UniqueQueryTypeOrExpression<Shape[K]['__queryType']> };
|
|
5143
4966
|
type ShapeUniqueColumns<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['unique'] extends string ? { [C in K]: UniqueQueryTypeOrExpression<Shape[K]['__queryType']> } : never }[keyof Shape];
|
|
5144
4967
|
type UniqueConstraints<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? string extends Shape[K]['data']['primaryKey'] ? never : Shape[K]['data']['primaryKey'] : Shape[K]['data']['unique'] extends string ? string extends Shape[K]['data']['unique'] ? never : Shape[K]['data']['unique'] : never }[keyof Shape];
|
|
5145
4968
|
type NoPrimaryKeyOption = 'error' | 'warning' | 'ignore';
|
|
@@ -5228,7 +5051,7 @@ type DbTableOptionScopes<Table extends string | undefined, Shape extends Column.
|
|
|
5228
5051
|
interface QueryBuilder extends Query.NotReadOnlyQuery {
|
|
5229
5052
|
returnType: undefined;
|
|
5230
5053
|
}
|
|
5231
|
-
declare class Db<Table extends string | undefined = undefined, Shape extends Column.QueryColumnsInit = Column.QueryColumnsInit,
|
|
5054
|
+
declare class Db<Table extends string | undefined = undefined, Shape extends Column.QueryColumnsInit = Column.QueryColumnsInit, Data extends MaybeArray<TableDataItem> = never, ColumnTypes = DefaultColumnTypes<ColumnSchemaConfig>, ReadOnly extends true | undefined = undefined, Options = never> extends QueryMethods<ColumnTypes> implements Query {
|
|
5232
5055
|
adapterNotInTransaction: Adapter;
|
|
5233
5056
|
qb: QueryBuilder;
|
|
5234
5057
|
table: Table;
|
|
@@ -5236,19 +5059,21 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
|
|
|
5236
5059
|
q: QueryData;
|
|
5237
5060
|
__isQuery: true;
|
|
5238
5061
|
__as: Table & string;
|
|
5239
|
-
__selectable: SelectableFromShape<
|
|
5062
|
+
__selectable: SelectableFromShape<ComputedColumnsFromOptions<Shape, Options>, Table>;
|
|
5240
5063
|
__readOnly: ReadOnly;
|
|
5241
|
-
__materialized:
|
|
5064
|
+
__materialized: Options extends {
|
|
5065
|
+
materialized: true;
|
|
5066
|
+
} ? true : undefined;
|
|
5242
5067
|
__hasSelect: boolean;
|
|
5243
5068
|
__hasWhere: boolean;
|
|
5244
5069
|
__defaults: { [K in { [K in keyof Shape]: unknown extends Shape[K]['data']['default'] ? never : K }[keyof Shape]]: true };
|
|
5245
|
-
__scopes: { [K in keyof
|
|
5246
|
-
__defaultSelect:
|
|
5070
|
+
__scopes: { [K in keyof MapTableScopesOption<Options>]: true };
|
|
5071
|
+
__defaultSelect: ColumnsShape.DefaultSelectKeys<Shape>;
|
|
5247
5072
|
baseQuery: Query;
|
|
5248
5073
|
columns: (keyof Shape)[];
|
|
5249
5074
|
__outputType: ColumnsShape.DefaultSelectOutput<Shape>;
|
|
5250
5075
|
__inputType: ColumnsShape.Input<Shape>;
|
|
5251
|
-
result: { [K in
|
|
5076
|
+
result: { [K in ColumnsShape.DefaultSelectKeys<Shape>]: Shape[K] };
|
|
5252
5077
|
returnType: undefined;
|
|
5253
5078
|
then: QueryThenShallowSimplifyArr<ColumnsShape.DefaultOutput<Shape>>;
|
|
5254
5079
|
windows: EmptyObject;
|
|
@@ -5258,10 +5083,10 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
|
|
|
5258
5083
|
relationQueries: EmptyObject;
|
|
5259
5084
|
withData: EmptyObject;
|
|
5260
5085
|
error: new (message: string, length: number, name: QueryErrorName) => QueryError<this>;
|
|
5261
|
-
internal: QueryInternal<{ [K in keyof
|
|
5086
|
+
internal: QueryInternal<TablePrimaryKeys<Shape> extends never ? never : { [K in keyof TablePrimaryKeys<Shape>]: (keyof TablePrimaryKeys<Shape> extends K ? never : keyof TablePrimaryKeys<Shape>) extends never ? TablePrimaryKeys<Shape>[K] : never }[keyof TablePrimaryKeys<Shape>], TablePrimaryKeys<Shape> | ShapeUniqueColumns<Shape> | TableDataItemsUniqueColumns<Shape, Data>, { [K in keyof Shape]: Shape[K]['data']['unique'] extends string ? K : never }[keyof Shape] | keyof TablePrimaryKeys<Shape>, TableDataItemsUniqueColumnTuples<Shape, Data>, UniqueConstraints<Shape> | TableDataItemsUniqueConstraints<Data>>;
|
|
5262
5087
|
catch: QueryCatch;
|
|
5263
|
-
shape:
|
|
5264
|
-
constructor(adapterNotInTransaction: Adapter, qb: QueryBuilder, table: Table | undefined, shape:
|
|
5088
|
+
shape: ComputedColumnsFromOptions<Shape, Options>;
|
|
5089
|
+
constructor(adapterNotInTransaction: Adapter, qb: QueryBuilder, table: Table | undefined, shape: ComputedColumnsFromOptions<Shape, Options>, columnTypes: ColumnTypes, asyncStorage: AsyncLocalStorage<AsyncState>, options: DbTableOptions<ColumnTypes, Table, ComputedColumnsFromOptions<Shape, Options>>, tableData?: TableData, viewData?: QueryInternal['viewData']);
|
|
5265
5090
|
/**
|
|
5266
5091
|
* When in transaction, returns a db adapter object for the transaction,
|
|
5267
5092
|
* returns a default adapter object otherwise.
|
|
@@ -5330,7 +5155,9 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
|
|
|
5330
5155
|
queryArrays<R extends any[] = any[]>(...args: SQLQueryArgs): Promise<QueryResult<R>>;
|
|
5331
5156
|
}
|
|
5332
5157
|
interface DbTableConstructor<ColumnTypes> {
|
|
5333
|
-
<Table extends string, Shape extends Column.QueryColumnsInit, Data extends MaybeArray<TableDataItem>, Options extends DbTableOptions<ColumnTypes, Table, Shape
|
|
5158
|
+
<Table extends string, Shape extends Column.QueryColumnsInit, Data extends MaybeArray<TableDataItem>, Options extends DbTableOptions<ColumnTypes, Table, Shape> | undefined>(table: Table, shape?: ((t: ColumnTypes) => Shape) | Shape, tableData?: TableDataFn<Shape, Data>, options?: Options): Db<Table, Shape, Data, ColumnTypes, Options extends {
|
|
5159
|
+
readOnly: true;
|
|
5160
|
+
} ? true : undefined, Options>;
|
|
5334
5161
|
}
|
|
5335
5162
|
interface DbSqlMethod<ColumnTypes> {
|
|
5336
5163
|
<T>(...args: StaticSQLArgs): RawSql<Column.Pick.QueryColumnOfType<T>, ColumnTypes>;
|
|
@@ -5348,7 +5175,7 @@ type MapTableScopesOption<T> = T extends {
|
|
|
5348
5175
|
} ? {
|
|
5349
5176
|
nonDeleted: unknown;
|
|
5350
5177
|
} : EmptyObject;
|
|
5351
|
-
interface DbResult<ColumnTypes> extends Db<undefined, EmptyObject, never,
|
|
5178
|
+
interface DbResult<ColumnTypes> extends Db<undefined, EmptyObject, never, ColumnTypes, never, never>, DbTableConstructor<ColumnTypes> {
|
|
5352
5179
|
adapterNotInTransaction: Adapter;
|
|
5353
5180
|
adapter: Adapter;
|
|
5354
5181
|
close: Adapter['close'];
|
|
@@ -6071,6 +5898,7 @@ interface ExpressionData extends HasBeforeAndBeforeSet {
|
|
|
6071
5898
|
expr?: Expression;
|
|
6072
5899
|
before?: QueryBeforeHook[];
|
|
6073
5900
|
dynamicBefore?: boolean;
|
|
5901
|
+
getColumn?: Column;
|
|
6074
5902
|
}
|
|
6075
5903
|
declare abstract class Expression<T extends Column.Pick.QueryColumn = Column.Pick.QueryColumn> {
|
|
6076
5904
|
abstract result: {
|
|
@@ -6433,6 +6261,166 @@ declare class QueryTransaction {
|
|
|
6433
6261
|
*/
|
|
6434
6262
|
recoverable<T>(this: T): T;
|
|
6435
6263
|
}
|
|
6264
|
+
interface ColumnsShape {
|
|
6265
|
+
[K: string]: Column;
|
|
6266
|
+
}
|
|
6267
|
+
declare namespace ColumnsShape {
|
|
6268
|
+
export type DefaultSelectKeys<S extends Column.QueryColumnsInit> = { [K in keyof S]: S[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof S];
|
|
6269
|
+
export type DefaultOutput<Set extends Column.QueryColumnsInit> = { [K in DefaultSelectKeys<Set>]: Set[K]['__outputType'] };
|
|
6270
|
+
export type Input<Shape extends Column.QueryColumnsInit, AppReadOnly = { [K in keyof Shape]: Shape[K]['data']['appReadOnly'] extends true ? K : never }[keyof Shape], Optional extends keyof Shape = { [K in keyof Shape]: Shape[K]['data']['optional'] extends true ? K : never }[keyof Shape]> = { [K in Exclude<keyof Shape, AppReadOnly | Optional>]: Shape[K]['__inputType'] } & { [K in Exclude<Optional, AppReadOnly>]?: Shape[K]['__inputType'] };
|
|
6271
|
+
export type InputPartial<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]?: Shape[K]['__inputType'] };
|
|
6272
|
+
export type Output<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
|
|
6273
|
+
export type DefaultSelectOutput<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof Shape]]: Shape[K]['__outputType'] };
|
|
6274
|
+
export interface MapToObjectColumn<Shape extends Column.QueryColumns> {
|
|
6275
|
+
dataType: 'object';
|
|
6276
|
+
__type: { [K in keyof Shape]: Shape[K]['__type'] };
|
|
6277
|
+
__outputType: ShallowSimplify<ObjectOutput<Shape>>;
|
|
6278
|
+
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] };
|
|
6279
|
+
operators: OperatorsAny;
|
|
6280
|
+
}
|
|
6281
|
+
export interface MapToNullableObjectColumn<Shape extends Column.QueryColumns> {
|
|
6282
|
+
dataType: 'object';
|
|
6283
|
+
__type: { [K in keyof Shape]: Shape[K]['__type'] };
|
|
6284
|
+
__outputType: ShallowSimplify<ObjectOutput<Shape>> | undefined;
|
|
6285
|
+
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] } | null;
|
|
6286
|
+
operators: OperatorsAny;
|
|
6287
|
+
}
|
|
6288
|
+
export interface MapToPluckColumn<Shape extends Column.QueryColumns> {
|
|
6289
|
+
dataType: 'array';
|
|
6290
|
+
__type: Shape['pluck']['__type'][];
|
|
6291
|
+
__outputType: Shape['pluck']['__outputType'][];
|
|
6292
|
+
__queryType: Shape['pluck']['__queryType'][];
|
|
6293
|
+
operators: OperatorsAny;
|
|
6294
|
+
}
|
|
6295
|
+
export interface MapToObjectArrayColumn<Shape extends Column.QueryColumns> {
|
|
6296
|
+
dataType: 'array';
|
|
6297
|
+
__type: { [K in keyof Shape]: Shape[K]['__type'] }[];
|
|
6298
|
+
__outputType: ShallowSimplify<ObjectOutput<Shape>>[];
|
|
6299
|
+
__queryType: { [K in keyof Shape]: Shape[K]['__queryType'] }[];
|
|
6300
|
+
operators: OperatorsAny;
|
|
6301
|
+
}
|
|
6302
|
+
type ObjectOutput<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
|
|
6303
|
+
export {};
|
|
6304
|
+
}
|
|
6305
|
+
interface SelectSelf extends PickQuerySelectable, PickQueryHasSelect, PickQueryDefaultSelect, PickQueryShape, PickQueryRelations, PickQueryResult, PickQueryReturnType, PickQueryWithData {}
|
|
6306
|
+
type SelectArgs<T extends SelectSelf> = ('*' | keyof T['__selectable'])[];
|
|
6307
|
+
interface SubQueryAddition<T extends PickQueryWithData> extends IsSubQuery {
|
|
6308
|
+
withData: T['withData'];
|
|
6309
|
+
}
|
|
6310
|
+
type SelectAsFnArg<T extends PickQueryRelationsWithData> = EmptyObject extends T['relations'] ? T : { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? RelationQueryMaybeSingle<T['relations'][K]> & SubQueryAddition<T> : K extends keyof T ? T[K] : never };
|
|
6311
|
+
interface SelectAsArg<T extends SelectSelf> {
|
|
6312
|
+
[K: string]: keyof T['__selectable'] | Expression | ((q: SelectAsFnArg<T>) => unknown);
|
|
6313
|
+
}
|
|
6314
|
+
type SelectAsFnReturnType = {
|
|
6315
|
+
result: Column.QueryColumns;
|
|
6316
|
+
returnType: Exclude<QueryReturnType, 'rows'>;
|
|
6317
|
+
} | Expression;
|
|
6318
|
+
interface SelectAsCheckReturnTypes {
|
|
6319
|
+
[K: string]: PropertyKey | Expression | ((q: never) => SelectAsFnReturnType);
|
|
6320
|
+
}
|
|
6321
|
+
type SelectReturnType<T extends PickQueryReturnType> = T['returnType'] extends 'valueOrThrow' ? 'oneOrThrow' : T extends 'value' ? 'one' : T['returnType'] extends 'pluck' ? 'all' : T['returnType'];
|
|
6322
|
+
type SelectResult<T extends SelectSelf, Columns extends PropertyKey[]> = { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? { [K in '*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number] as T['__selectable'][K]['as']]: T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown) : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in '*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number] as T['__selectable'][K]['as']]: T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown)> : T[K] };
|
|
6323
|
+
type SelectResultObj<T extends SelectSelf, Obj> = Obj extends SelectAsCheckReturnTypes ? { [K in keyof T]: K extends '__hasSelect' ? true : K extends '__selectable' ? T['__selectable'] & SelectAsSelectable<Obj> : K extends 'result' ? { [K in T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? keyof Obj | keyof T['result'] : keyof Obj]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : K extends keyof T['result'] ? T['result'][K] : never } : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? keyof Obj | keyof T['result'] : keyof Obj]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : K extends keyof T['result'] ? T['result'][K] : never }> : T[K] } : `Invalid return type of ${{ [K in keyof Obj]: Obj[K] extends ((...args: any[]) => any) ? ReturnType<Obj[K]> extends SelectAsFnReturnType ? never : K : never }[keyof Obj] & string}`;
|
|
6324
|
+
type SelectResultColumnsAndObj<T extends SelectSelf, Columns extends PropertyKey[], Obj> = { [K in keyof T]: K extends '__hasSelect' ? true : K extends '__selectable' ? T['__selectable'] & SelectAsSelectable<Obj> : K extends 'result' ? // Combine previously selected items, all columns if * was provided,
|
|
6325
|
+
{ [K in ('*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number]) | keyof Obj as K extends Columns[number] ? T['__selectable'][K]['as'] : K]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown) : K extends 'returnType' ? SelectReturnType<T> : K extends 'then' ? QueryThenByReturnType<SelectReturnType<T>, { [K in ('*' extends Columns[number] ? Exclude<Columns[number], '*'> | T['__defaultSelect'] : Columns[number]) | keyof Obj as K extends Columns[number] ? T['__selectable'][K]['as'] : K]: K extends keyof Obj ? SelectAsValueResult<T, Obj[K]> : T['__selectable'][K]['column'] } & (T['__hasSelect'] extends (T['returnType'] extends 'value' | 'valueOrThrow' ? never : true) ? Omit<T['result'], Columns[number]> : unknown)> : T[K] };
|
|
6326
|
+
interface AllowedRelationOneQueryForSelectable extends IsSubQuery {
|
|
6327
|
+
result: Column.QueryColumns;
|
|
6328
|
+
returnType: 'value' | 'valueOrThrow' | 'one' | 'oneOrThrow';
|
|
6329
|
+
}
|
|
6330
|
+
type SelectAsSelectable<Obj> = UnionToIntersection<{ [K in keyof Obj]: Obj[K] extends ((q: never) => infer R extends AllowedRelationOneQueryForSelectable) ? { [C in R['returnType'] extends 'value' | 'valueOrThrow' ? K : keyof R['result'] as R['returnType'] extends 'value' | 'valueOrThrow' ? K : `${K & string}.${C & string}`]: {
|
|
6331
|
+
as: C;
|
|
6332
|
+
column: R['returnType'] extends 'value' | 'valueOrThrow' ? R['result']['value'] : R['result'][C & keyof R['result']];
|
|
6333
|
+
} } : never }[keyof Obj]>;
|
|
6334
|
+
type SelectAsValueResult<T extends SelectSelf, Arg> = Arg extends keyof T['__selectable'] ? T['__selectable'][Arg]['column'] : Arg extends Expression ? Arg['result']['value'] : Arg extends ((q: never) => IsQuery) ? SelectSubQueryResult<ReturnType<Arg>> : Arg extends ((q: never) => Expression) ? ReturnType<Arg>['result']['value'] : Arg extends ((q: never) => IsQuery | Expression) ? SelectSubQueryResult<Exclude<ReturnType<Arg>, Expression>> | Exclude<ReturnType<Arg>, IsQuery>['result']['value'] : never;
|
|
6335
|
+
type SelectSubQueryResult<Arg extends SelectSelf> = Arg['returnType'] extends undefined | 'all' ? ColumnsShape.MapToObjectArrayColumn<Arg['result']> : Arg['returnType'] extends 'value' | 'valueOrThrow' ? Arg['result']['value'] : Arg['returnType'] extends 'pluck' ? ColumnsShape.MapToPluckColumn<Arg['result']> : Arg['returnType'] extends 'one' ? ColumnsShape.MapToNullableObjectColumn<Arg['result']> : ColumnsShape.MapToObjectColumn<Arg['result']>;
|
|
6336
|
+
declare function _querySelect<T extends SelectSelf, Columns extends SelectArgs<T>>(q: T, columns: Columns): SelectResult<T, Columns>;
|
|
6337
|
+
declare function _querySelect<T extends SelectSelf, Obj extends SelectAsArg<T>>(q: T, obj: Obj): SelectResultObj<T, Obj>;
|
|
6338
|
+
declare function _querySelect<T extends SelectSelf, Columns extends SelectArgs<T>, Obj extends SelectAsArg<T>>(q: T, args: [...columns: Columns, obj: Obj]): SelectResultColumnsAndObj<T, Columns, Obj>;
|
|
6339
|
+
declare class Select {
|
|
6340
|
+
/**
|
|
6341
|
+
* Takes a list of columns to be selected, and by default, the query builder will select all columns of the table.
|
|
6342
|
+
*
|
|
6343
|
+
* The last argument can be an object. Keys of the object are column aliases, value can be a column name, sub-query, or raw SQL expression.
|
|
6344
|
+
*
|
|
6345
|
+
* ```ts
|
|
6346
|
+
* import { sql } from './baseTable'
|
|
6347
|
+
*
|
|
6348
|
+
* // select columns of the table:
|
|
6349
|
+
* db.table.select('id', 'name', { idAlias: 'id' });
|
|
6350
|
+
*
|
|
6351
|
+
* // accepts columns with table names:
|
|
6352
|
+
* db.table.select('user.id', 'user.name', { nameAlias: 'user.name' });
|
|
6353
|
+
*
|
|
6354
|
+
* // table name may refer to the current table or a joined table:
|
|
6355
|
+
* db.table
|
|
6356
|
+
* .join(db.message, 'authorId', 'user.id')
|
|
6357
|
+
* .select('user.name', 'message.text', { textAlias: 'message.text' });
|
|
6358
|
+
*
|
|
6359
|
+
* // select value from the sub-query,
|
|
6360
|
+
* // this sub-query should return a single record and a single column:
|
|
6361
|
+
* db.table.select({
|
|
6362
|
+
* subQueryResult: Otherdb.table.select('column').take(),
|
|
6363
|
+
* });
|
|
6364
|
+
*
|
|
6365
|
+
* // select raw SQL value, specify the returning type via <generic> syntax:
|
|
6366
|
+
* db.table.select({
|
|
6367
|
+
* raw: sql<number>`1 + 2`,
|
|
6368
|
+
* });
|
|
6369
|
+
*
|
|
6370
|
+
* // select raw SQL value, the resulting type can be set by providing a column type in such way:
|
|
6371
|
+
* db.table.select({
|
|
6372
|
+
* raw: sql`1 + 2`.type((t) => t.integer()),
|
|
6373
|
+
* });
|
|
6374
|
+
*
|
|
6375
|
+
* // same raw SQL query as above, but the sql is returned from a callback
|
|
6376
|
+
* db.table.select({
|
|
6377
|
+
* raw: () => sql`1 + 2`.type((t) => t.integer()),
|
|
6378
|
+
* });
|
|
6379
|
+
* ```
|
|
6380
|
+
*
|
|
6381
|
+
* When you use the ORM and defined relations, `select` can also accept callbacks with related table queries:
|
|
6382
|
+
*
|
|
6383
|
+
* ```ts
|
|
6384
|
+
* await db.author.select({
|
|
6385
|
+
* allBooks: (q) => q.books,
|
|
6386
|
+
* firstBook: (q) => q.books.order({ createdAt: 'ASC' }).take(),
|
|
6387
|
+
* booksCount: (q) => q.books.count(),
|
|
6388
|
+
* });
|
|
6389
|
+
* ```
|
|
6390
|
+
*
|
|
6391
|
+
* When you're selecting a relation that's connected via `belongsTo` or `hasOne`, it becomes available to use in `order` or in `where`:
|
|
6392
|
+
*
|
|
6393
|
+
* ```ts
|
|
6394
|
+
* // select books with their authors included, order by author name and filter by author column:
|
|
6395
|
+
* await db.books
|
|
6396
|
+
* .select({
|
|
6397
|
+
* author: (q) => q.author,
|
|
6398
|
+
* })
|
|
6399
|
+
* .order('author.name')
|
|
6400
|
+
* .where({ 'author.isPopular': true });
|
|
6401
|
+
* ```
|
|
6402
|
+
*/
|
|
6403
|
+
select<T extends SelectSelf, Columns extends SelectArgs<T>>(this: T, ...args: Columns): SelectResult<T, Columns>;
|
|
6404
|
+
select<T extends SelectSelf, Obj extends SelectAsArg<T>>(this: T, obj: Obj): SelectResultObj<T, Obj>;
|
|
6405
|
+
select<T extends SelectSelf, Columns extends SelectArgs<T>, Obj extends SelectAsArg<T>>(this: T, ...args: [...columns: Columns, obj: Obj]): SelectResultColumnsAndObj<T, Columns, Obj>;
|
|
6406
|
+
/**
|
|
6407
|
+
* When querying the table or creating records, all columns are selected by default,
|
|
6408
|
+
* but updating and deleting queries are returning affected row counts by default.
|
|
6409
|
+
*
|
|
6410
|
+
* Use `selectAll` to select all columns. If the `.select` method was applied before it will be discarded.
|
|
6411
|
+
*
|
|
6412
|
+
* ```ts
|
|
6413
|
+
* const selectFull = await db.table
|
|
6414
|
+
* .select('id', 'name') // discarded by `selectAll`
|
|
6415
|
+
* .selectAll();
|
|
6416
|
+
*
|
|
6417
|
+
* const updatedFull = await db.table.selectAll().where(conditions).update(data);
|
|
6418
|
+
*
|
|
6419
|
+
* const deletedFull = await db.table.selectAll().where(conditions).delete();
|
|
6420
|
+
* ```
|
|
6421
|
+
*/
|
|
6422
|
+
selectAll<T extends SelectSelf>(this: T): SelectResult<T, ['*']>;
|
|
6423
|
+
}
|
|
6436
6424
|
type SelectItem = string | SelectAs | Expression | undefined;
|
|
6437
6425
|
interface SelectAs {
|
|
6438
6426
|
selectAs: SelectAsValue;
|
|
@@ -6615,18 +6603,18 @@ declare namespace Column {
|
|
|
6615
6603
|
unique: Name;
|
|
6616
6604
|
};
|
|
6617
6605
|
};
|
|
6618
|
-
export type Nullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T | null> : T['operators'][K] } : T[K] };
|
|
6606
|
+
export type Nullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
|
|
6619
6607
|
export type QueryColumnToNullable<C> = { [K in keyof C]: K extends '__outputType' | '__queryType' ? C[K] | null : C[K] };
|
|
6620
6608
|
export type QueryColumnToOptional<C> = { [K in keyof C]: K extends '__outputType' ? C[K] | undefined : C[K] };
|
|
6621
6609
|
interface DataNullable {
|
|
6622
6610
|
isNullable: true;
|
|
6623
6611
|
optional: true;
|
|
6624
6612
|
}
|
|
6625
|
-
export interface OperatorsNullable<
|
|
6626
|
-
equals: Operator<
|
|
6627
|
-
not: Operator<
|
|
6628
|
-
isDistinctFrom: Operator<
|
|
6629
|
-
isNotDistinctFrom: Operator<
|
|
6613
|
+
export interface OperatorsNullable<Column extends Column.Pick.QueryColumn> {
|
|
6614
|
+
equals: Operator<Column['__queryType'] | null, Column>;
|
|
6615
|
+
not: Operator<Column['__queryType'] | null, Column>;
|
|
6616
|
+
isDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6617
|
+
isNotDistinctFrom: Operator<Column['__queryType'] | null, Column>;
|
|
6630
6618
|
}
|
|
6631
6619
|
export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends '__inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
|
|
6632
6620
|
export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? (Output extends null ? never : Output) | (unknown extends T['__nullType'] ? null : T['__nullType']) : Output : K extends 'outputSchema' ? null extends T['__type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
|
|
@@ -6819,6 +6807,8 @@ declare namespace Column {
|
|
|
6819
6807
|
identity?: TableData.Identity;
|
|
6820
6808
|
generated?: Data.Generated;
|
|
6821
6809
|
readonly?: boolean;
|
|
6810
|
+
valueToArray?: boolean;
|
|
6811
|
+
skipValueToArray?: boolean;
|
|
6822
6812
|
}
|
|
6823
6813
|
export namespace Data {
|
|
6824
6814
|
interface Check {
|
|
@@ -8742,11 +8732,13 @@ declare const getColumnBaseType: (column: Column.Pick.Data, domainsMap: DbStruct
|
|
|
8742
8732
|
interface ColumnDataComputedProp extends ColumnDataSelectSqlProp {
|
|
8743
8733
|
computed?: Expression;
|
|
8744
8734
|
}
|
|
8745
|
-
type ComputedColumnsFromOptions<
|
|
8735
|
+
type ComputedColumnsFromOptions<Shape, Options> = Options extends {
|
|
8736
|
+
computed: (...args: any) => infer R;
|
|
8737
|
+
} ? { [K in (keyof Shape | keyof R) & string]: K extends keyof Shape ? Shape[K] : K extends keyof R ? R[K] extends QueryOrExpression<unknown> ? R[K]['result']['value'] : R[K] extends (() => {
|
|
8746
8738
|
result: {
|
|
8747
8739
|
value: infer Value extends Column.Pick.QueryColumn;
|
|
8748
8740
|
};
|
|
8749
|
-
}) ? Value : never } :
|
|
8741
|
+
}) ? Value : never : never } : Shape;
|
|
8750
8742
|
interface ComputedOptionsConfig {
|
|
8751
8743
|
[K: string]: QueryOrExpression<unknown> | ReturnsQueryOrExpression<unknown>;
|
|
8752
8744
|
}
|
|
@@ -8967,7 +8959,7 @@ type SelectAllColumn = string | SelectAllColumnExpression;
|
|
|
8967
8959
|
interface QueryData extends QueryDataAliases, PickQueryDataParsers, HasHookSelect, MutativeQueriesSelectRelationsQueryData {
|
|
8968
8960
|
type: QueryType;
|
|
8969
8961
|
adapter: Adapter;
|
|
8970
|
-
|
|
8962
|
+
selectShape: ColumnsShape;
|
|
8971
8963
|
handleResult: HandleResult;
|
|
8972
8964
|
catch?: boolean;
|
|
8973
8965
|
returnType: QueryReturnType;
|
|
@@ -9830,6 +9822,12 @@ declare class QueryUpsert {
|
|
|
9830
9822
|
*/
|
|
9831
9823
|
upsert<T extends UpsertThis, Update extends UpdateData<T>>(this: T, data: UpsertData<T, Update>): UpsertResult<T>;
|
|
9832
9824
|
}
|
|
9825
|
+
interface QueryGetSelf extends PickQuerySelectable, PickQueryRelationsWithData {}
|
|
9826
|
+
type GetArg<T extends QueryGetSelf> = GetStringArg<T> | Expression | ((q: SelectAsFnArg<T>) => Expression | Query.Pick.SingleValueResult);
|
|
9827
|
+
type GetStringArg<T extends PickQuerySelectable> = keyof T['__selectable'] & string;
|
|
9828
|
+
type ResolveGetArgColumn<Arg> = Arg extends Expression ? Arg['result']['value'] : Arg extends ((q: never) => infer R) ? R extends Expression ? R['result']['value'] : R extends Query.Pick.SingleValueResult ? R['result']['value'] : never : never;
|
|
9829
|
+
type GetResult<T extends QueryGetSelf, Arg extends GetArg<T>> = Arg extends string ? SetQueryReturnsValueOrThrow<T, Arg> : SetQueryReturnsColumnOrThrow<T, ResolveGetArgColumn<Arg>>;
|
|
9830
|
+
type GetResultOptional<T extends QueryGetSelf, Arg extends GetArg<T>> = Arg extends string ? SetQueryReturnsValueOptional<T, Arg> : SetQueryReturnsColumnOptional<T, ResolveGetArgColumn<Arg>>;
|
|
9833
9831
|
declare class QueryGet {
|
|
9834
9832
|
/**
|
|
9835
9833
|
* `.get` returns a single value, adds `LIMIT 1` to the query, and accepts a column name or a raw SQL expression.
|
|
@@ -10111,6 +10109,28 @@ declare class QueryTruncate {
|
|
|
10111
10109
|
cascade?: boolean;
|
|
10112
10110
|
}): SetQueryReturnsVoid<T>;
|
|
10113
10111
|
}
|
|
10112
|
+
declare class QueryExistsMethods {
|
|
10113
|
+
/**
|
|
10114
|
+
* Use `exists()` to check if there is at least one record-matching condition.
|
|
10115
|
+
*
|
|
10116
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
10117
|
+
*
|
|
10118
|
+
* ```ts
|
|
10119
|
+
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
10120
|
+
* ```
|
|
10121
|
+
*/
|
|
10122
|
+
exists<T extends QueryGetSelf>(this: T): SetQueryReturnsColumnOrThrow<T, BooleanQueryColumn>;
|
|
10123
|
+
/**
|
|
10124
|
+
* Use `notExists()` to check if there are no matching records.
|
|
10125
|
+
*
|
|
10126
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
10127
|
+
*
|
|
10128
|
+
* ```ts
|
|
10129
|
+
* const exists: boolean = await db.table.where(...conditions).notExists();
|
|
10130
|
+
* ```
|
|
10131
|
+
*/
|
|
10132
|
+
notExists<T extends QueryGetSelf>(this: T): SetQueryReturnsColumnOrThrow<T, BooleanQueryColumn>;
|
|
10133
|
+
}
|
|
10114
10134
|
type GroupArgs<T extends PickQueryResult> = ({ [K in keyof T['result']]: T['result'][K]['dataType'] extends 'array' | 'object' | 'runtimeComputed' ? never : K }[keyof T['result']] | Expression)[];
|
|
10115
10135
|
interface QueryHelperQuery<T extends PickQuerySelectableShapeAs> extends MergeQueryArg {
|
|
10116
10136
|
returnType: QueryReturnType;
|
|
@@ -10149,7 +10169,7 @@ interface NarrowPluckTypeResult<T extends PickQueryResultReturnType, Narrow> ext
|
|
|
10149
10169
|
}
|
|
10150
10170
|
type QueryIfResult<T extends PickQueryResultReturnType, R extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? { [K in keyof T['result'] | keyof R['result']]: K extends keyof T['result'] ? K extends keyof R['result'] ? R['result'][K] | T['result'][K] : T['result'][K] : Column.Modifiers.QueryColumnToOptional<R['result'][K]> } : K extends 'then' ? QueryIfResultThen<T, R> : T[K] };
|
|
10151
10171
|
type QueryIfResultThen<T extends PickQueryResultReturnType, R extends PickQueryResult> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'value' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType']> : T['returnType'] extends 'rows' ? QueryThen<(T['result'][keyof T['result']]['__outputType'] | R['result'][keyof R['result']]['__outputType'])[][]> : T['returnType'] extends 'pluck' ? QueryThen<(T['result']['pluck']['__outputType'] | R['result']['pluck']['__outputType'])[]> : QueryThen<void>;
|
|
10152
|
-
interface QueryMethods<ColumnTypes> extends QueryClone, QueryAsMethods, AggregateMethods, QueryDistinct, Select, FromMethods, QueryJoin, QueryLimitOffset, CteQuery, Union, QueryJsonMethods, QueryCreate, QueryCreateFrom, QueryUpdate, QueryDelete, QueryStorage, QueryTransaction, QueryTruncate, For, Where, SearchMethods, Clear, Having, QueryCatchers, QueryLog, QueryOrder, QueryWithSchema, QueryHooks, QueryUpsert, QueryOrCreate, QueryGet, QueryPluck, MergeQueryMethods, QuerySql<ColumnTypes>, QueryTransform, QueryMap, QueryScope, SoftDeleteMethods, QueryExpressions, QueryWrap, QueryWindow {}
|
|
10172
|
+
interface QueryMethods<ColumnTypes> extends QueryClone, QueryAsMethods, AggregateMethods, QueryDistinct, Select, FromMethods, QueryJoin, QueryLimitOffset, CteQuery, Union, QueryJsonMethods, QueryCreate, QueryCreateFrom, QueryUpdate, QueryDelete, QueryStorage, QueryTransaction, QueryTruncate, For, Where, SearchMethods, Clear, Having, QueryCatchers, QueryLog, QueryOrder, QueryWithSchema, QueryHooks, QueryUpsert, QueryOrCreate, QueryGet, QueryPluck, MergeQueryMethods, QuerySql<ColumnTypes>, QueryTransform, QueryMap, QueryScope, SoftDeleteMethods, QueryExpressions, QueryWrap, QueryWindow, QueryExistsMethods {}
|
|
10153
10173
|
declare class QueryMethods<ColumnTypes> {
|
|
10154
10174
|
/**
|
|
10155
10175
|
* `.all` is a default behavior, that returns an array of objects:
|
|
@@ -10212,6 +10232,15 @@ declare class QueryMethods<ColumnTypes> {
|
|
|
10212
10232
|
* ```
|
|
10213
10233
|
*/
|
|
10214
10234
|
exec<T>(this: T): SetQueryReturnsVoid<T>;
|
|
10235
|
+
/**
|
|
10236
|
+
* For relation selects, `require` changes LEFT JOIN LATERAL to JOIN LATERAL.
|
|
10237
|
+
*
|
|
10238
|
+
* ```ts
|
|
10239
|
+
* // only the records that have `related` will be loaded:
|
|
10240
|
+
* await db.table.select({ related: (q) => q.related.required() });
|
|
10241
|
+
* ```
|
|
10242
|
+
*/
|
|
10243
|
+
require<T extends PickQueryResultReturnType>(this: T): QueryRequire<T>;
|
|
10215
10244
|
/**
|
|
10216
10245
|
* Call `toSQL` on a query to get an object with a `text` SQL string and a `values` array of binding values:
|
|
10217
10246
|
*
|
|
@@ -10400,7 +10429,7 @@ declare class QueryMethods<ColumnTypes> {
|
|
|
10400
10429
|
* // all the following queries will resolve into empty arrays
|
|
10401
10430
|
*
|
|
10402
10431
|
* await db.user.select({
|
|
10403
|
-
* pets: (q) => q.pets.
|
|
10432
|
+
* pets: (q) => q.pets.require().none(),
|
|
10404
10433
|
* });
|
|
10405
10434
|
*
|
|
10406
10435
|
* await db.user.join((q) => q.pets.none());
|
|
@@ -10472,7 +10501,7 @@ declare class QueryMethods<ColumnTypes> {
|
|
|
10472
10501
|
*
|
|
10473
10502
|
* @param fn - helper function
|
|
10474
10503
|
*/
|
|
10475
|
-
makeHelper<T extends PickQuerySelectableShapeAs, Args extends unknown[], Result extends MergeQueryArg>(this: T, fn: (q: T, ...args: Args) => Result): QueryHelper<T, Args, Result>;
|
|
10504
|
+
makeHelper<T extends PickQuerySelectableShapeAs, Args extends unknown[], Result extends MergeQueryArg | Expression>(this: T, fn: (q: T, ...args: Args) => Result): QueryHelper<T, Args, Result>;
|
|
10476
10505
|
/**
|
|
10477
10506
|
* `useHelper` allows to use {@link makeHelper} in different queries:
|
|
10478
10507
|
*
|
|
@@ -10681,6 +10710,9 @@ declare namespace Query {
|
|
|
10681
10710
|
type Args<T extends Order.ArgThis> = Order.Args<T>;
|
|
10682
10711
|
}
|
|
10683
10712
|
namespace Pick {
|
|
10713
|
+
interface ReturnType {
|
|
10714
|
+
returnType: QueryReturnType;
|
|
10715
|
+
}
|
|
10684
10716
|
interface SingleValueResult {
|
|
10685
10717
|
result: {
|
|
10686
10718
|
value: Column.Pick.OutputType;
|
|
@@ -10701,6 +10733,7 @@ type SetQueryReturnsAll<T extends PickQueryResult> = { [K in keyof T]: K extends
|
|
|
10701
10733
|
type SetQueryReturnsAllResult<T extends PickQueryResult, Result extends Column.QueryColumns> = { [K in keyof T]: K extends 'returnType' ? 'all' : K extends 'result' ? Result : K extends 'then' ? QueryThenShallowSimplifyArr<T['result']> : T[K] } & QueryHasWhere;
|
|
10702
10734
|
type QueryTakeOptional<T extends PickQueryResultReturnType> = T['returnType'] extends 'value' | 'pluck' | 'void' ? T : T['returnType'] extends 'valueOrThrow' ? { [K in keyof T]: K extends 'returnType' ? 'value' : K extends 'then' ? QueryThen<T['result']['value']['__outputType'] | undefined> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'one' : K extends 'then' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<T['result']>> : T[K] };
|
|
10703
10735
|
type QueryManyTakeOptional<T extends PickQueryResultReturnType> = { [K in keyof T]: K extends 'returnType' ? 'one' : K extends 'then' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<T['result']>> : T[K] };
|
|
10736
|
+
type QueryRequire<T extends PickQueryResultReturnType> = T['returnType'] extends QueryReturnTypeAll | 'valueOrThrow' | 'pluck' | 'void' ? T : T['returnType'] extends 'value' ? { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Exclude<T['result']['value']['__outputType'], undefined>> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
|
|
10704
10737
|
type QueryTake<T extends PickQueryResultReturnType> = T['returnType'] extends 'valueOrThrow' | 'pluck' | 'void' ? T : T['returnType'] extends 'value' ? { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Exclude<T['result']['value']['__outputType'], undefined>> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
|
|
10705
10738
|
type QueryManyTake<T extends PickQueryResultReturnType> = { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
|
|
10706
10739
|
type SetQueryReturnsOne<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
|
|
@@ -11106,4 +11139,4 @@ declare const testTransaction: {
|
|
|
11106
11139
|
*/
|
|
11107
11140
|
close(arg: Arg$1): Promise<void>;
|
|
11108
11141
|
};
|
|
11109
|
-
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type
|
|
11142
|
+
export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, type OperatorsText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RefreshMaterializedViewOptions, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, refreshMaterializedView, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|