pqb 0.52.3 → 0.54.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 +236 -206
- package/dist/index.js +5523 -5519
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5523 -5514
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as orchid_core from 'orchid-core';
|
|
|
3
3
|
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, IsQuery, PickQueryTableMetaResult, PickQueryShape, PickQueryTable, PickQueryMetaReturnType, RecordUnknown, Expression, MaybeArray, ColumnTypesBase, TemplateLiteralArgs, QueryColumn, EmptyObject, QueryColumns, MaybePromise, FnUnknownToUnknown, QueryMetaBase, QueryReturnType, RecordString, ColumnsShapeBase, ColumnsParsers, HookSelect, BatchParsers, QueryLogObject, QueryLogger, QueryDataTransform, ExpressionChain, ColumnSchemaConfig, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, ExpressionData, StaticSQLArgs, SQLQueryArgs, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, QueryThenByQuery, ColumnShapeInput, SelectableBase, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, PickQueryResult, ValExpression, PickOutputType, QueryThen, DateColumnData, ColumnToCodeCtx, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ColumnTypeBase, ParseColumn, ParseNullColumn, EncodeColumn, QueryColumnsInit, QueryLogOptions, DefaultSelectColumns, DefaultSelectOutput, QueryThenShallowSimplifyArr, QueryCatch, TransactionState, QueryColumnOfDataType, PickQueryUniqueProperties, PickQueryMetaResult, PickQueryTableMetaResultInputType, UnionToIntersection, AfterCommitStandaloneHook, getValueKey, QueryThenByReturnType, QueryMetaIsSubQuery, PickQueryReturnType, QueryReturnTypeAll, QueryReturnTypeOptional, QueryThenShallowSimplifyOptional, QueryThenShallowSimplify, PickQueryResultReturnType, PickQueryResultReturnTypeUniqueColumns, PickQueryTableMetaShape, QueryInternalBase, PickType, RecordKeyTrue, ColumnShapeOutput, OperatorsNullable, UniqueColumn, TimestampHelpers, ShallowSimplify, Codes, ColumnDataCheckBase } from 'orchid-core';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
|
+
import { QueryResult as QueryResult$1, QueryBuilder as QueryBuilder$1, QueryInternal as QueryInternal$1, Adapter as Adapter$1, QueryData as QueryData$1 } from 'pqb';
|
|
6
7
|
|
|
7
8
|
interface TypeParsers {
|
|
8
9
|
[K: number]: (input: string) => unknown;
|
|
@@ -248,7 +249,7 @@ type UnionKind = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' | 'EXCEPT
|
|
|
248
249
|
type OnConflictTarget = string | string[] | Expression | {
|
|
249
250
|
constraint: string;
|
|
250
251
|
};
|
|
251
|
-
type OnConflictSet = RecordUnknown
|
|
252
|
+
type OnConflictSet$1 = RecordUnknown;
|
|
252
253
|
type OnConflictMerge = string | string[] | {
|
|
253
254
|
except: string | string[];
|
|
254
255
|
};
|
|
@@ -350,6 +351,7 @@ interface QueryDataJoinTo extends PickQueryTable, PickQueryQ {
|
|
|
350
351
|
interface HandleResult {
|
|
351
352
|
(q: Query, returnType: QueryReturnType, result: QueryResult, isSubQuery?: true): MaybePromise<unknown>;
|
|
352
353
|
}
|
|
354
|
+
type WithItems = (WithItem | undefined)[];
|
|
353
355
|
interface CommonQueryData {
|
|
354
356
|
adapter: Adapter;
|
|
355
357
|
shape: ColumnsShape;
|
|
@@ -360,7 +362,10 @@ interface CommonQueryData {
|
|
|
360
362
|
returningMany?: boolean;
|
|
361
363
|
wrapInTransaction?: boolean;
|
|
362
364
|
throwOnNotFound?: boolean;
|
|
363
|
-
with?:
|
|
365
|
+
with?: WithItems;
|
|
366
|
+
insertWith?: {
|
|
367
|
+
[rowIndex: number]: WithItems;
|
|
368
|
+
};
|
|
364
369
|
withShapes?: WithConfigs;
|
|
365
370
|
joinTo?: QueryDataJoinTo;
|
|
366
371
|
joinedShapes?: JoinedShapes;
|
|
@@ -477,19 +482,19 @@ interface SelectQueryData extends CommonQueryData {
|
|
|
477
482
|
mode?: 'NO WAIT' | 'SKIP LOCKED';
|
|
478
483
|
};
|
|
479
484
|
}
|
|
480
|
-
type CreateKind = 'object' | '
|
|
485
|
+
type CreateKind = 'object' | 'from';
|
|
481
486
|
interface InsertQueryData extends CommonQueryData {
|
|
482
487
|
type: 'insert';
|
|
483
488
|
kind: CreateKind;
|
|
484
489
|
columns: string[];
|
|
485
|
-
values: unknown[][] |
|
|
490
|
+
values: unknown[][] | {
|
|
486
491
|
from: Query;
|
|
487
492
|
values?: unknown[][];
|
|
488
493
|
};
|
|
489
494
|
join?: JoinItem[];
|
|
490
495
|
onConflict?: {
|
|
491
496
|
target?: OnConflictTarget;
|
|
492
|
-
set?: OnConflictSet;
|
|
497
|
+
set?: OnConflictSet$1;
|
|
493
498
|
merge?: OnConflictMerge;
|
|
494
499
|
};
|
|
495
500
|
}
|
|
@@ -502,7 +507,7 @@ interface UpdateQueryDataObject {
|
|
|
502
507
|
interface UpdatedAtDataInjector {
|
|
503
508
|
(data: UpdateQueryDataItem[]): UpdateQueryDataItem | void;
|
|
504
509
|
}
|
|
505
|
-
type UpdateQueryDataItem = UpdateQueryDataObject |
|
|
510
|
+
type UpdateQueryDataItem = UpdateQueryDataObject | UpdatedAtDataInjector;
|
|
506
511
|
interface UpdateQueryData extends CommonQueryData {
|
|
507
512
|
type: 'update';
|
|
508
513
|
updateData: UpdateQueryDataItem[];
|
|
@@ -3466,6 +3471,75 @@ declare class SoftDeleteMethods {
|
|
|
3466
3471
|
hardDelete<T extends QueryWithSoftDelete>(this: T, ..._args: DeleteArgs<T>): DeleteResult<T>;
|
|
3467
3472
|
}
|
|
3468
3473
|
|
|
3474
|
+
interface DbSqlQuery {
|
|
3475
|
+
<T extends QueryResultRow = QueryResultRow>(...args: SQLQueryArgs): Promise<QueryResult$1<T>>;
|
|
3476
|
+
/**
|
|
3477
|
+
* Returns an array of records:
|
|
3478
|
+
*
|
|
3479
|
+
* ```ts
|
|
3480
|
+
* const array: T[] = await db.$query.records<T>`SELECT * FROM table`;
|
|
3481
|
+
* ```
|
|
3482
|
+
*/
|
|
3483
|
+
records<T extends RecordUnknown = RecordUnknown>(...args: SQLQueryArgs): Promise<T[]>;
|
|
3484
|
+
/**
|
|
3485
|
+
* Returns a single record, throws [NotFoundError](/guide/error-handling) if not found.
|
|
3486
|
+
*
|
|
3487
|
+
* ```ts
|
|
3488
|
+
* const one: T = await db.$query.take<T>`SELECT * FROM table LIMIT 1`;
|
|
3489
|
+
* ```
|
|
3490
|
+
*/
|
|
3491
|
+
take<T extends RecordUnknown = RecordUnknown>(...args: SQLQueryArgs): Promise<T>;
|
|
3492
|
+
/**
|
|
3493
|
+
* Returns a single record or `undefined` when not found.
|
|
3494
|
+
*
|
|
3495
|
+
* ```ts
|
|
3496
|
+
* const maybeOne: T | undefined = await db.$query
|
|
3497
|
+
* .takeOptional<T>`SELECT * FROM table LIMIT 1`;
|
|
3498
|
+
* ```
|
|
3499
|
+
*/
|
|
3500
|
+
takeOptional<T extends RecordUnknown = RecordUnknown>(...args: SQLQueryArgs): Promise<T | undefined>;
|
|
3501
|
+
/**
|
|
3502
|
+
* Returns array of tuples of the values:
|
|
3503
|
+
*
|
|
3504
|
+
* ```ts
|
|
3505
|
+
* const arrayOfTuples: [number, string][] = await db.$query.rows<
|
|
3506
|
+
* [number, string]
|
|
3507
|
+
* >`SELECT id, name FROM table`;
|
|
3508
|
+
* ```
|
|
3509
|
+
*/
|
|
3510
|
+
rows<T extends unknown[]>(...args: SQLQueryArgs): Promise<T[]>;
|
|
3511
|
+
/**
|
|
3512
|
+
* Returns a flat array of values for a single column:
|
|
3513
|
+
*
|
|
3514
|
+
* ```ts
|
|
3515
|
+
* const strings: string[] = await db.$query.pluck<string>`SELECT name FROM table`;
|
|
3516
|
+
* ```
|
|
3517
|
+
*/
|
|
3518
|
+
pluck<T>(...args: SQLQueryArgs): Promise<T[]>;
|
|
3519
|
+
/**
|
|
3520
|
+
* Returns a single value, throws [NotFoundError](/guide/error-handling) if not found.
|
|
3521
|
+
*
|
|
3522
|
+
* ```ts
|
|
3523
|
+
* const value: number = await db.$query.get<number>`SELECT 1`;
|
|
3524
|
+
* ```
|
|
3525
|
+
*/
|
|
3526
|
+
get<T>(...args: SQLQueryArgs): Promise<T>;
|
|
3527
|
+
/**
|
|
3528
|
+
* Returns a single value or `undefined` when not found.
|
|
3529
|
+
*
|
|
3530
|
+
* ```ts
|
|
3531
|
+
* const value: number | undefined = await db.$query.getOptional<number>`SELECT 1`;
|
|
3532
|
+
* ```
|
|
3533
|
+
*/
|
|
3534
|
+
getOptional<T>(...args: SQLQueryArgs): Promise<T | undefined>;
|
|
3535
|
+
}
|
|
3536
|
+
declare const performQuery: <Result = QueryResult$1<any>>(q: {
|
|
3537
|
+
qb: QueryBuilder$1;
|
|
3538
|
+
internal: QueryInternal$1;
|
|
3539
|
+
adapter: Adapter$1;
|
|
3540
|
+
q: QueryData$1;
|
|
3541
|
+
}, args: SQLQueryArgs, method: 'query' | 'arrays') => Promise<Result>;
|
|
3542
|
+
|
|
3469
3543
|
type ShapeColumnPrimaryKeys<Shape extends QueryColumnsInit> = {
|
|
3470
3544
|
[K in {
|
|
3471
3545
|
[K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? K : never;
|
|
@@ -3550,10 +3624,12 @@ interface TableMeta<Table extends string | undefined, Shape extends QueryColumns
|
|
|
3550
3624
|
selectable: SelectableFromShape<ShapeWithComputed, Table>;
|
|
3551
3625
|
defaultSelect: DefaultSelectColumns<Shape>;
|
|
3552
3626
|
}
|
|
3553
|
-
|
|
3627
|
+
interface QueryBuilder extends Query {
|
|
3628
|
+
returnType: undefined;
|
|
3629
|
+
}
|
|
3554
3630
|
declare class Db<Table extends string | undefined = undefined, Shape extends QueryColumnsInit = QueryColumnsInit, PrimaryKeys = never, UniqueColumns = never, UniqueColumnTuples = never, UniqueConstraints = never, ColumnTypes = DefaultColumnTypes<ColumnSchemaConfig>, ShapeWithComputed extends QueryColumnsInit = Shape, Scopes extends RecordUnknown | undefined = EmptyObject> extends QueryMethods<ColumnTypes> implements Query {
|
|
3555
3631
|
adapter: Adapter;
|
|
3556
|
-
|
|
3632
|
+
qb: QueryBuilder;
|
|
3557
3633
|
table: Table;
|
|
3558
3634
|
shape: ShapeWithComputed;
|
|
3559
3635
|
columnTypes: ColumnTypes;
|
|
@@ -3578,7 +3654,7 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Que
|
|
|
3578
3654
|
[K in keyof Shape]: Shape[K]['data']['unique'] extends string ? K : never;
|
|
3579
3655
|
}[keyof Shape] | keyof PrimaryKeys, UniqueColumnTuples, UniqueConstraints>;
|
|
3580
3656
|
catch: QueryCatch;
|
|
3581
|
-
constructor(adapter: Adapter,
|
|
3657
|
+
constructor(adapter: Adapter, qb: QueryBuilder, table: Table, shape: ShapeWithComputed, columnTypes: ColumnTypes, transactionStorage: AsyncLocalStorage<TransactionState>, options: DbTableOptions<ColumnTypes, Table, ShapeWithComputed>, tableData?: TableData);
|
|
3582
3658
|
[inspect.custom](): string;
|
|
3583
3659
|
/**
|
|
3584
3660
|
* Use `query` to perform raw SQL queries.
|
|
@@ -3620,9 +3696,10 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Que
|
|
|
3620
3696
|
*
|
|
3621
3697
|
* @param args - SQL template literal, or an object { raw: string, values?: unknown[] }
|
|
3622
3698
|
*/
|
|
3623
|
-
query
|
|
3699
|
+
get query(): DbSqlQuery;
|
|
3700
|
+
private _query?;
|
|
3624
3701
|
/**
|
|
3625
|
-
*
|
|
3702
|
+
* Performs a SQL query, returns a db result with array of arrays instead of objects:
|
|
3626
3703
|
*
|
|
3627
3704
|
* ```ts
|
|
3628
3705
|
* const value = 1;
|
|
@@ -3742,23 +3819,23 @@ interface DbResult<ColumnTypes> extends Db<string, never, never, never, never, n
|
|
|
3742
3819
|
declare const createDb: <SchemaConfig extends ColumnSchemaConfig<ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>> = DefaultSchemaConfig, ColumnTypes = DefaultColumnTypes<SchemaConfig>>({ log, logger, snakeCase, schemaConfig, columnTypes: ctOrFn, ...options }: DbOptions<SchemaConfig, ColumnTypes>) => DbResult<ColumnTypes>;
|
|
3743
3820
|
declare const _initQueryBuilder: (adapter: Adapter, columnTypes: unknown, transactionStorage: AsyncLocalStorage<TransactionState>, commonOptions: DbTableOptions<unknown, undefined, QueryColumns>, options: DbSharedOptions) => Db;
|
|
3744
3821
|
|
|
3745
|
-
interface
|
|
3746
|
-
|
|
3822
|
+
interface ToSqlOptionsInternal extends ToSQLOptions {
|
|
3823
|
+
aliasValue?: true;
|
|
3824
|
+
skipBatchCheck?: true;
|
|
3825
|
+
}
|
|
3826
|
+
interface ToSQLCtx extends ToSqlOptionsInternal {
|
|
3827
|
+
qb: QueryBuilder;
|
|
3747
3828
|
q: QueryData;
|
|
3748
3829
|
sql: string[];
|
|
3749
3830
|
values: unknown[];
|
|
3750
|
-
aliasValue?: true;
|
|
3751
3831
|
}
|
|
3752
3832
|
interface ToSQLOptions {
|
|
3753
3833
|
values?: unknown[];
|
|
3754
3834
|
}
|
|
3755
|
-
interface ToSqlOptionsInternal extends ToSQLOptions {
|
|
3756
|
-
aliasValue?: true;
|
|
3757
|
-
}
|
|
3758
3835
|
interface ToSQLQuery {
|
|
3759
3836
|
__isQuery: Query['__isQuery'];
|
|
3760
3837
|
q: Query['q'];
|
|
3761
|
-
|
|
3838
|
+
qb: Query['qb'];
|
|
3762
3839
|
table?: Query['table'];
|
|
3763
3840
|
internal: QueryInternal;
|
|
3764
3841
|
relations: Query['relations'];
|
|
@@ -3794,7 +3871,6 @@ declare const getQueryAs: (q: {
|
|
|
3794
3871
|
as?: string;
|
|
3795
3872
|
};
|
|
3796
3873
|
}) => string;
|
|
3797
|
-
declare const makeRegexToFindInSql: (value: string) => RegExp;
|
|
3798
3874
|
/**
|
|
3799
3875
|
* In `select`, `update`, `create` it's possible to pass a callback with a sub-query.
|
|
3800
3876
|
* This function resolves such a sub-query.
|
|
@@ -4318,7 +4394,7 @@ type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends k
|
|
|
4318
4394
|
} & {
|
|
4319
4395
|
[K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K>;
|
|
4320
4396
|
};
|
|
4321
|
-
type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] |
|
|
4397
|
+
type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] | ((q: T) => QueryOrExpression<T['inputType'][K]>);
|
|
4322
4398
|
type CreateRelationsData<T extends CreateSelf, BelongsToData> = CreateDataWithDefaultsForRelations<T, keyof T['meta']['defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & ([BelongsToData] extends [never] ? EmptyObject : BelongsToData) & T['relations'][keyof T['relations']]['optionalDataForCreate'];
|
|
4323
4399
|
type CreateBelongsToData<T extends CreateSelf> = [
|
|
4324
4400
|
T['relations'][keyof T['relations']]['dataForCreate']
|
|
@@ -4341,11 +4417,11 @@ type InsertRawOrFromResult<T extends CreateSelf> = T['meta']['hasSelect'] extend
|
|
|
4341
4417
|
type CreateManyResult<T extends CreateSelf, BT> = T extends {
|
|
4342
4418
|
isCount: true;
|
|
4343
4419
|
} ? SetQueryKindResult<T, 'create', NarrowCreateResult<T, BT>> : T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllKindResult<T, 'create', NarrowCreateResult<T, BT>> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnKindResult<T, 'create', NarrowCreateResult<T, BT>> : SetQueryKindResult<T, 'create', NarrowCreateResult<T, BT>>;
|
|
4344
|
-
type
|
|
4420
|
+
type CreateManyFromResult<T extends CreateSelf> = T extends {
|
|
4345
4421
|
isCount: true;
|
|
4346
4422
|
} ? SetQueryKind<T, 'create'> : T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllKind<T, 'create'> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnKind<T, 'create'> : SetQueryKind<T, 'create'>;
|
|
4347
4423
|
type InsertManyResult<T extends CreateSelf, BT> = T['meta']['hasSelect'] extends true ? T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllKindResult<T, 'create', NarrowCreateResult<T, BT>> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnKindResult<T, 'create', NarrowCreateResult<T, BT>> : SetQueryKindResult<T, 'create', NarrowCreateResult<T, BT>> : SetQueryReturnsRowCountMany<T, 'create'>;
|
|
4348
|
-
type
|
|
4424
|
+
type InsertManyFromResult<T extends CreateSelf> = T['meta']['hasSelect'] extends true ? T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllKind<T, 'create'> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnKind<T, 'create'> : SetQueryKind<T, 'create'> : SetQueryReturnsRowCountMany<T, 'create'>;
|
|
4349
4425
|
/**
|
|
4350
4426
|
* When creating a record with a *belongs to* nested record,
|
|
4351
4427
|
* un-nullify foreign key columns of the result.
|
|
@@ -4360,22 +4436,6 @@ type NarrowCreateResult<T extends CreateSelf, Bt> = EmptyObject extends T['relat
|
|
|
4360
4436
|
[K in keyof T['result']]: K extends T['relations'][keyof T['relations']]['omitForeignKeyInCreate'] ? QueryColumn<Exclude<T['result'][K]['type'], null>, T['result'][K]['operators']> : T['result'][K];
|
|
4361
4437
|
};
|
|
4362
4438
|
type IgnoreResult<T extends CreateSelf> = T['returnType'] extends 'oneOrThrow' ? QueryTakeOptional<T> : T['returnType'] extends 'valueOrThrow' ? SetQueryReturnsColumnOptional<T, T['result']['value']> : T;
|
|
4363
|
-
interface CreateRawData<T extends CreateSelf> {
|
|
4364
|
-
columns: (keyof T['shape'])[];
|
|
4365
|
-
values: Expression;
|
|
4366
|
-
}
|
|
4367
|
-
interface CreateManyRawData<T extends CreateSelf> {
|
|
4368
|
-
columns: (keyof T['shape'])[];
|
|
4369
|
-
values: Expression[];
|
|
4370
|
-
}
|
|
4371
|
-
type RawRequiredColumns<T extends CreateSelf> = {
|
|
4372
|
-
[K in keyof T['inputType'] as K extends keyof T['meta']['defaults'] ? never : null | undefined extends T['inputType'][K] ? never : K]: true;
|
|
4373
|
-
};
|
|
4374
|
-
type CreateRawArgs<T extends CreateSelf, Arg extends {
|
|
4375
|
-
columns: (keyof T['shape'])[];
|
|
4376
|
-
}> = keyof RawRequiredColumns<T> extends Arg['columns'][number] ? [data: Arg] : [
|
|
4377
|
-
`Missing required columns: ${Exclude<keyof RawRequiredColumns<T> & string, Arg['columns'][number]>}`
|
|
4378
|
-
];
|
|
4379
4439
|
type OnConflictArg<T extends PickQueryUniqueProperties> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'] | Expression | {
|
|
4380
4440
|
constraint: T['internal']['uniqueConstraints'];
|
|
4381
4441
|
};
|
|
@@ -4397,28 +4457,24 @@ declare const _queryCreate: <T extends CreateSelf, BT extends CreateBelongsToDat
|
|
|
4397
4457
|
declare const _queryInsert: <T extends CreateSelf, BT extends CreateBelongsToData<T>>(q: T, data: CreateData<T, BT>) => InsertResult<T, BT>;
|
|
4398
4458
|
declare const _queryCreateMany: <T extends CreateSelf, BT extends CreateBelongsToData<T>>(q: T, data: CreateData<T, BT>[]) => CreateManyResult<T, BT>;
|
|
4399
4459
|
declare const _queryInsertMany: <T extends CreateSelf, BT extends CreateBelongsToData<T>>(q: T, data: CreateData<T, BT>[]) => InsertManyResult<T, BT>;
|
|
4400
|
-
declare const _queryCreateRaw: <T extends CreateSelf>(q: T, args: CreateRawArgs<T, CreateRawData<T>>) => CreateRawOrFromResult<T>;
|
|
4401
|
-
declare const _queryInsertRaw: <T extends CreateSelf>(q: T, args: CreateRawArgs<T, CreateRawData<T>>) => InsertRawOrFromResult<T>;
|
|
4402
|
-
declare const _queryCreateManyRaw: <T extends CreateSelf>(q: T, args: CreateRawArgs<T, CreateManyRawData<T>>) => CreateManyRawOrFromResult<T>;
|
|
4403
|
-
declare const _queryInsertManyRaw: <T extends CreateSelf>(q: T, args: CreateRawArgs<T, CreateManyRawData<T>>) => InsertManyRawOrFromResult<T>;
|
|
4404
4460
|
interface QueryReturningOne extends IsQuery {
|
|
4405
4461
|
result: QueryColumns;
|
|
4406
4462
|
returnType: 'one' | 'oneOrThrow';
|
|
4407
4463
|
}
|
|
4408
4464
|
declare const _queryCreateFrom: <T extends CreateSelf, Q extends QueryReturningOne>(q: T, query: Q, data?: Omit<CreateData<T, CreateBelongsToData<T>>, keyof Q['result']>) => CreateRawOrFromResult<T>;
|
|
4409
4465
|
declare const _queryInsertFrom: <T extends CreateSelf, Q extends QueryReturningOne>(q: T, query: Q, data?: Omit<CreateData<T, CreateBelongsToData<T>>, keyof Q['result']>) => InsertRawOrFromResult<T>;
|
|
4410
|
-
declare const _queryCreateManyFrom: <T extends CreateSelf>(q: T, query: IsQuery) =>
|
|
4411
|
-
declare const _queryInsertManyFrom: <T extends CreateSelf>(q: T, query: IsQuery) =>
|
|
4466
|
+
declare const _queryCreateManyFrom: <T extends CreateSelf>(q: T, query: IsQuery) => CreateManyFromResult<T>;
|
|
4467
|
+
declare const _queryInsertManyFrom: <T extends CreateSelf>(q: T, query: IsQuery) => InsertManyFromResult<T>;
|
|
4412
4468
|
declare const _queryDefaults: <T extends CreateSelf, Data extends Partial<CreateData<T, CreateBelongsToData<T>>>>(q: T, data: Data) => AddQueryDefaults<T, { [K in keyof Data]: true; }>;
|
|
4413
4469
|
/**
|
|
4414
4470
|
* Names of all create methods,
|
|
4415
4471
|
* is used in {@link RelationQuery} to remove these methods if chained relation shouldn't have them,
|
|
4416
4472
|
* for the case of has one/many through.
|
|
4417
4473
|
*/
|
|
4418
|
-
type CreateMethodsNames = 'create' | 'insert' | 'createMany' | 'insertMany' | '
|
|
4474
|
+
type CreateMethodsNames = 'create' | 'insert' | 'createMany' | 'insertMany' | 'createFrom' | 'insertFrom' | 'createManyFrom' | 'insertManyFrom';
|
|
4419
4475
|
declare class Create {
|
|
4420
4476
|
/**
|
|
4421
|
-
* `create` and `insert`
|
|
4477
|
+
* `create` and `insert` create a single record.
|
|
4422
4478
|
*
|
|
4423
4479
|
* Each column may accept a specific value, a raw SQL, or a query that returns a single value.
|
|
4424
4480
|
*
|
|
@@ -4440,14 +4496,18 @@ declare class Create {
|
|
|
4440
4496
|
*
|
|
4441
4497
|
* // query that returns a single value
|
|
4442
4498
|
* // returning multiple values will result in Postgres error
|
|
4443
|
-
* column2: db.otherTable.get('someColumn'),
|
|
4499
|
+
* column2: () => db.otherTable.get('someColumn'),
|
|
4500
|
+
*
|
|
4501
|
+
* // nesting creates, updates, deletes produces a single SQL
|
|
4502
|
+
* column4: () => db.otherTable.create(data).get('someColumn'),
|
|
4503
|
+
* column5: (q) => q.relatedTable.find(id).update(data).get('someColumn'),
|
|
4444
4504
|
* });
|
|
4445
4505
|
* ```
|
|
4446
4506
|
*
|
|
4447
|
-
*
|
|
4507
|
+
* Creational methods can be used in {@link WithMethods.with} expressions:
|
|
4448
4508
|
*
|
|
4449
4509
|
* ```ts
|
|
4450
|
-
* db.$
|
|
4510
|
+
* db.$qb
|
|
4451
4511
|
* // create a record in one table
|
|
4452
4512
|
* .with('a', db.table.select('id').create(data))
|
|
4453
4513
|
* // create a record in other table using the first table record id
|
|
@@ -4486,8 +4546,17 @@ declare class Create {
|
|
|
4486
4546
|
* const createdCount = await db.table.insertMany([data, data, data]);
|
|
4487
4547
|
* ```
|
|
4488
4548
|
*
|
|
4549
|
+
* When nesting creates, a separate create query will be executed for every time it's used:
|
|
4550
|
+
*
|
|
4551
|
+
* ```ts
|
|
4552
|
+
* // will be performed twice, even though it is defined once
|
|
4553
|
+
* const nestedCreate = db.otherTable.create(data).get('column');
|
|
4554
|
+
*
|
|
4555
|
+
* await db.table.createMany([{ column: nestedCreate }, { column: nestedCreate }]);
|
|
4556
|
+
* ```
|
|
4557
|
+
*
|
|
4489
4558
|
* Because of a limitation of Postgres protocol, queries having more than **65535** of values are going to fail in runtime.
|
|
4490
|
-
* To solve this seamlessly, OrchidORM will automatically batch such queries, and wrap them into a transaction, unless they are already in a transaction.
|
|
4559
|
+
* To solve this seamlessly, `OrchidORM` will automatically batch such queries, and wrap them into a transaction, unless they are already in a transaction.
|
|
4491
4560
|
*
|
|
4492
4561
|
* ```ts
|
|
4493
4562
|
* // OK: executes 2 inserts wrapped into a transaction
|
|
@@ -4508,56 +4577,6 @@ declare class Create {
|
|
|
4508
4577
|
* @param data - array of records data, may have values, raw SQL, queries, relation operations
|
|
4509
4578
|
*/
|
|
4510
4579
|
insertMany<T extends CreateSelf, BT extends CreateBelongsToData<T>>(this: T, data: CreateData<T, BT>[]): InsertManyResult<T, BT>;
|
|
4511
|
-
/**
|
|
4512
|
-
* `createRaw` and `insertRaw` are for creating one record with a raw SQL expression.
|
|
4513
|
-
*
|
|
4514
|
-
* Provided SQL will be wrapped into parens for a single `VALUES` record.
|
|
4515
|
-
*
|
|
4516
|
-
* If the table has a column with runtime defaults (defined with callbacks), the value will be appended to your SQL.
|
|
4517
|
-
*
|
|
4518
|
-
* `columns` are type-checked to contain all required columns.
|
|
4519
|
-
*
|
|
4520
|
-
* ```ts
|
|
4521
|
-
* const oneRecord = await db.table.createRaw({
|
|
4522
|
-
* columns: ['name', 'amount'],
|
|
4523
|
-
* values: sql`'name', random()`,
|
|
4524
|
-
* });
|
|
4525
|
-
* ```
|
|
4526
|
-
*
|
|
4527
|
-
* @param args - object with columns list and raw SQL for values
|
|
4528
|
-
*/
|
|
4529
|
-
createRaw<T extends CreateSelf>(this: T, ...args: CreateRawArgs<T, CreateRawData<T>>): CreateRawOrFromResult<T>;
|
|
4530
|
-
/**
|
|
4531
|
-
* Works exactly as {@link createRaw}, except that it returns inserted row count by default.
|
|
4532
|
-
*
|
|
4533
|
-
* @param args - object with columns list and raw SQL for values
|
|
4534
|
-
*/
|
|
4535
|
-
insertRaw<T extends CreateSelf>(this: T, ...args: CreateRawArgs<T, CreateRawData<T>>): InsertRawOrFromResult<T>;
|
|
4536
|
-
/**
|
|
4537
|
-
* `createManyRaw` and `insertManyRaw` are for creating many record with raw SQL expressions.
|
|
4538
|
-
*
|
|
4539
|
-
* Takes array of SQL expressions, each of them will be wrapped into parens for `VALUES` records.
|
|
4540
|
-
*
|
|
4541
|
-
* If the table has a column with runtime defaults (defined with callbacks), function will be called for each SQL and the value will be appended.
|
|
4542
|
-
*
|
|
4543
|
-
* `columns` are type-checked to contain all required columns.
|
|
4544
|
-
*
|
|
4545
|
-
* ```ts
|
|
4546
|
-
* const manyRecords = await db.table.createManyRaw({
|
|
4547
|
-
* columns: ['name', 'amount'],
|
|
4548
|
-
* values: [sql`'one', 2`, sql`'three', 4`],
|
|
4549
|
-
* });
|
|
4550
|
-
* ```
|
|
4551
|
-
*
|
|
4552
|
-
* @param args - object with columns list and array of raw SQL for values
|
|
4553
|
-
*/
|
|
4554
|
-
createManyRaw<T extends CreateSelf>(this: T, ...args: CreateRawArgs<T, CreateManyRawData<T>>): CreateManyRawOrFromResult<T>;
|
|
4555
|
-
/**
|
|
4556
|
-
* Works exactly as {@link createManyRaw}, except that it returns inserted row count by default.
|
|
4557
|
-
*
|
|
4558
|
-
* @param args - object with columns list and array of raw SQL for values
|
|
4559
|
-
*/
|
|
4560
|
-
insertManyRaw<T extends CreateSelf>(this: T, ...args: CreateRawArgs<T, CreateManyRawData<T>>): InsertManyRawOrFromResult<T>;
|
|
4561
4580
|
/**
|
|
4562
4581
|
* These methods are for creating a single record, for batch creating see {@link createManyFrom}.
|
|
4563
4582
|
*
|
|
@@ -4579,6 +4598,10 @@ declare class Create {
|
|
|
4579
4598
|
* // optional argument:
|
|
4580
4599
|
* {
|
|
4581
4600
|
* key: 'value',
|
|
4601
|
+
* // supports sql, nested select, create, update, delete queries
|
|
4602
|
+
* fromSql: () => sql`custom sql`,
|
|
4603
|
+
* fromQuery: () => db.otherTable.find(id).update(data).get('column'),
|
|
4604
|
+
* fromRelated: (q) => q.relatedTable.create(data).get('column'),
|
|
4582
4605
|
* },
|
|
4583
4606
|
* );
|
|
4584
4607
|
* ```
|
|
@@ -4618,13 +4641,13 @@ declare class Create {
|
|
|
4618
4641
|
*
|
|
4619
4642
|
* @param query - query to create new records from
|
|
4620
4643
|
*/
|
|
4621
|
-
createManyFrom<T extends CreateSelf>(this: T, query: IsQuery):
|
|
4644
|
+
createManyFrom<T extends CreateSelf>(this: T, query: IsQuery): CreateManyFromResult<T>;
|
|
4622
4645
|
/**
|
|
4623
4646
|
* Works exactly as {@link createManyFrom}, except that it returns inserted row count by default.
|
|
4624
4647
|
*
|
|
4625
4648
|
* @param query - query to create new records from
|
|
4626
4649
|
*/
|
|
4627
|
-
insertManyFrom<T extends CreateSelf>(this: T, query: IsQuery):
|
|
4650
|
+
insertManyFrom<T extends CreateSelf>(this: T, query: IsQuery): InsertManyFromResult<T>;
|
|
4628
4651
|
/**
|
|
4629
4652
|
* `defaults` allows setting values that will be used later in `create`.
|
|
4630
4653
|
*
|
|
@@ -4796,6 +4819,9 @@ declare class Create {
|
|
|
4796
4819
|
*/
|
|
4797
4820
|
onConflictDoNothing<T extends CreateSelf, Arg extends OnConflictArg<T>>(this: T, arg?: Arg): IgnoreResult<T>;
|
|
4798
4821
|
}
|
|
4822
|
+
type OnConflictSet<T extends CreateSelf> = {
|
|
4823
|
+
[K in keyof T['inputType']]?: T['inputType'][K] | (() => QueryOrExpression<T['inputType'][K]>);
|
|
4824
|
+
};
|
|
4799
4825
|
declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflictArg<T> | undefined> {
|
|
4800
4826
|
private query;
|
|
4801
4827
|
private onConflict;
|
|
@@ -4806,30 +4832,21 @@ declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflic
|
|
|
4806
4832
|
* Updates the record with a given data when conflict occurs.
|
|
4807
4833
|
*
|
|
4808
4834
|
* ```ts
|
|
4809
|
-
* db.table.create(data).onConflict('column').set({
|
|
4810
|
-
* description: 'setting different data on conflict',
|
|
4811
|
-
* });
|
|
4812
|
-
* ```
|
|
4813
|
-
*
|
|
4814
|
-
* The `set` can take a raw SQL expression:
|
|
4815
|
-
*
|
|
4816
|
-
* ```ts
|
|
4817
|
-
* db.table
|
|
4818
|
-
* .create(data)
|
|
4819
|
-
* .onConflict()
|
|
4820
|
-
* .set(sql`raw SQL expression`);
|
|
4821
|
-
*
|
|
4822
|
-
* // update records only on certain conditions
|
|
4823
4835
|
* db.table
|
|
4824
4836
|
* .create(data)
|
|
4825
4837
|
* .onConflict('email')
|
|
4826
|
-
* .set({
|
|
4838
|
+
* .set({
|
|
4839
|
+
* // supports plain values and SQL expressions
|
|
4840
|
+
* key: 'value',
|
|
4841
|
+
* fromSql: () => sql`custom sql`,
|
|
4842
|
+
* })
|
|
4843
|
+
* // to update records only on certain conditions
|
|
4827
4844
|
* .where({ ...certainConditions });
|
|
4828
4845
|
* ```
|
|
4829
4846
|
*
|
|
4830
|
-
* @param set - object containing new column values
|
|
4847
|
+
* @param set - object containing new column values
|
|
4831
4848
|
*/
|
|
4832
|
-
set(set:
|
|
4849
|
+
set(set: OnConflictSet<T>): T;
|
|
4833
4850
|
/**
|
|
4834
4851
|
* Available only after `onConflict`.
|
|
4835
4852
|
*
|
|
@@ -4927,7 +4944,7 @@ declare class Delete {
|
|
|
4927
4944
|
* `delete` can be used in {@link WithMethods.with} expressions:
|
|
4928
4945
|
*
|
|
4929
4946
|
* ```ts
|
|
4930
|
-
* db.$
|
|
4947
|
+
* db.$qb
|
|
4931
4948
|
* // delete a record in one table
|
|
4932
4949
|
* .with('a', db.table.find(1).select('id').delete())
|
|
4933
4950
|
* // delete a record in other table using the first table record id
|
|
@@ -5914,11 +5931,12 @@ type WithSqlResult<T extends PickQueryWithDataColumnTypes, Name extends string,
|
|
|
5914
5931
|
} : K extends keyof T['withData'] ? T['withData'][K] : never;
|
|
5915
5932
|
} : T[K];
|
|
5916
5933
|
};
|
|
5934
|
+
declare const moveQueryValueToWith: (q: Query, withStore: object, value: Query, set: RecordUnknown, key: string, withKey: string | number) => void;
|
|
5917
5935
|
declare class WithMethods {
|
|
5918
5936
|
/**
|
|
5919
5937
|
* Use `with` to add a Common Table Expression (CTE) to the query.
|
|
5920
5938
|
*
|
|
5921
|
-
* `with` can be chained to any table on `db` instance, or to `db.$
|
|
5939
|
+
* `with` can be chained to any table on `db` instance, or to `db.$qb`,
|
|
5922
5940
|
* note that in the latter case it won't have customized column types to use for typing SQL.
|
|
5923
5941
|
*
|
|
5924
5942
|
* ```ts
|
|
@@ -5929,8 +5947,8 @@ declare class WithMethods {
|
|
|
5929
5947
|
* q.select({ column: (q) => sql`123`.type((t) => t.customColumn()) }),
|
|
5930
5948
|
* );
|
|
5931
5949
|
*
|
|
5932
|
-
* // only default columns are available when using off `$
|
|
5933
|
-
* db.$
|
|
5950
|
+
* // only default columns are available when using off `$qb`
|
|
5951
|
+
* db.$qb.with('x', (q) =>
|
|
5934
5952
|
* q.select({ column: (q) => sql`123`.type((t) => t.integer()) }),
|
|
5935
5953
|
* );
|
|
5936
5954
|
* ```
|
|
@@ -5977,7 +5995,7 @@ declare class WithMethods {
|
|
|
5977
5995
|
* One `WITH` expression can reference the other:
|
|
5978
5996
|
*
|
|
5979
5997
|
* ```ts
|
|
5980
|
-
* db.$
|
|
5998
|
+
* db.$qb
|
|
5981
5999
|
* .with('a', db.table.select('id', 'name'))
|
|
5982
6000
|
* .with('b', (q) => q.from('a').where({ key: 'value' }))
|
|
5983
6001
|
* .from('b');
|
|
@@ -6001,7 +6019,7 @@ declare class WithMethods {
|
|
|
6001
6019
|
*
|
|
6002
6020
|
* For example, it is useful for loading a tree of categories, where one category can include many other categories.
|
|
6003
6021
|
*
|
|
6004
|
-
* Similarly to [with](#with), `withRecursive` can be chained to any table or `db.$
|
|
6022
|
+
* Similarly to [with](#with), `withRecursive` can be chained to any table or `db.$qb`.
|
|
6005
6023
|
*
|
|
6006
6024
|
* For the first example, consider the employee table, an employee may or may not have a manager.
|
|
6007
6025
|
*
|
|
@@ -6019,7 +6037,7 @@ declare class WithMethods {
|
|
|
6019
6037
|
* The task is to load all subordinates of the manager with the id 1.
|
|
6020
6038
|
*
|
|
6021
6039
|
* ```ts
|
|
6022
|
-
* db.$
|
|
6040
|
+
* db.$qb
|
|
6023
6041
|
* .withRecursive(
|
|
6024
6042
|
* 'subordinates',
|
|
6025
6043
|
* // the base, anchor query: find the manager to begin recursion with
|
|
@@ -6042,7 +6060,7 @@ declare class WithMethods {
|
|
|
6042
6060
|
* You can customize it by passing options after the name.
|
|
6043
6061
|
*
|
|
6044
6062
|
* ```ts
|
|
6045
|
-
* db.$
|
|
6063
|
+
* db.$qb
|
|
6046
6064
|
* .withRecursive(
|
|
6047
6065
|
* 'subordinates',
|
|
6048
6066
|
* {
|
|
@@ -6062,7 +6080,7 @@ declare class WithMethods {
|
|
|
6062
6080
|
* ```ts
|
|
6063
6081
|
* import { sql } from './baseTable';
|
|
6064
6082
|
*
|
|
6065
|
-
* db.$
|
|
6083
|
+
* db.$qb
|
|
6066
6084
|
* .withRecursive(
|
|
6067
6085
|
* 't',
|
|
6068
6086
|
* // select `1 AS n` for the base query
|
|
@@ -6088,7 +6106,7 @@ declare class WithMethods {
|
|
|
6088
6106
|
/**
|
|
6089
6107
|
* Use `withSql` to add a Common Table Expression (CTE) based on a custom SQL.
|
|
6090
6108
|
*
|
|
6091
|
-
* Similarly to [with](#with), `withRecursive` can be chained to any table or `db.$
|
|
6109
|
+
* Similarly to [with](#with), `withRecursive` can be chained to any table or `db.$qb`.
|
|
6092
6110
|
*
|
|
6093
6111
|
* ```ts
|
|
6094
6112
|
* import { sql } from './baseTable';
|
|
@@ -6253,7 +6271,6 @@ type UpdateColumn<T extends UpdateSelf, Key extends keyof T['inputType']> = T['i
|
|
|
6253
6271
|
}) => QueryOrExpression<T['inputType'][Key]>);
|
|
6254
6272
|
type UpdateRelationData<T extends UpdateSelf, Rel extends RelationConfigBase> = T['returnType'] extends undefined | 'all' ? Rel['dataForUpdate'] : Rel['dataForUpdateOne'];
|
|
6255
6273
|
type UpdateArg<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? UpdateData<T> : never;
|
|
6256
|
-
type UpdateRawArgs<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? SQLQueryArgs : never;
|
|
6257
6274
|
type UpdateResult<T extends UpdateSelf> = T['meta']['hasSelect'] extends true ? SetQueryKind<T, 'update'> : T['returnType'] extends undefined | 'all' ? SetQueryReturnsRowCountMany<T, 'update'> : SetQueryReturnsRowCount<T, 'update'>;
|
|
6258
6275
|
type NumericColumns<T extends PickQueryShape> = {
|
|
6259
6276
|
[K in keyof T['shape']]: Exclude<T['shape'][K]['queryType'], string> extends number | bigint | null ? K : never;
|
|
@@ -6271,7 +6288,6 @@ interface UpdateCtxCollect {
|
|
|
6271
6288
|
}
|
|
6272
6289
|
declare const _queryChangeCounter: <T extends UpdateSelf>(self: T, op: string, data: ChangeCountArg<T>) => never;
|
|
6273
6290
|
declare const _queryUpdate: <T extends UpdateSelf>(query: T, arg: UpdateArg<T>) => UpdateResult<T>;
|
|
6274
|
-
declare const _queryUpdateRaw: <T extends UpdateSelf>(q: T, sql: Expression) => UpdateResult<T>;
|
|
6275
6291
|
declare const _queryUpdateOrThrow: <T extends UpdateSelf>(q: T, arg: UpdateArg<T>) => UpdateResult<T>;
|
|
6276
6292
|
declare class Update {
|
|
6277
6293
|
/**
|
|
@@ -6326,14 +6342,14 @@ declare class Update {
|
|
|
6326
6342
|
*
|
|
6327
6343
|
* await db.table.where({ ...conditions }).update({
|
|
6328
6344
|
* // set the column to a specific value
|
|
6329
|
-
*
|
|
6345
|
+
* value: 123,
|
|
6330
6346
|
*
|
|
6331
|
-
* // use
|
|
6332
|
-
*
|
|
6347
|
+
* // use custom SQL to update the column
|
|
6348
|
+
* fromSql: () => sql`2 + 2`,
|
|
6333
6349
|
*
|
|
6334
6350
|
* // use query that returns a single value
|
|
6335
6351
|
* // returning multiple values will result in Postgres error
|
|
6336
|
-
*
|
|
6352
|
+
* fromQuery: () => db.otherTable.get('someColumn'),
|
|
6337
6353
|
*
|
|
6338
6354
|
* // select a single value from a related record
|
|
6339
6355
|
* fromRelation: (q) => q.relatedTable.get('someColumn'),
|
|
@@ -6343,9 +6359,48 @@ declare class Update {
|
|
|
6343
6359
|
* });
|
|
6344
6360
|
* ```
|
|
6345
6361
|
*
|
|
6362
|
+
* `update` can be used in [with](/guide/advanced-queries#with) expressions:
|
|
6363
|
+
*
|
|
6364
|
+
* ```ts
|
|
6365
|
+
* db.$qb
|
|
6366
|
+
* // update record in one table
|
|
6367
|
+
* .with('a', db.table.find(1).select('id').update(data))
|
|
6368
|
+
* // update record in other table using the first table record id
|
|
6369
|
+
* .with('b', (q) =>
|
|
6370
|
+
* db.otherTable
|
|
6371
|
+
* .find(1)
|
|
6372
|
+
* .select('id')
|
|
6373
|
+
* .update({
|
|
6374
|
+
* ...otherData,
|
|
6375
|
+
* aId: () => q.from('a').get('id'),
|
|
6376
|
+
* }),
|
|
6377
|
+
* )
|
|
6378
|
+
* .from('b');
|
|
6379
|
+
*
|
|
6380
|
+
* `update` can be used in {@link WithMethods.with} expressions:
|
|
6381
|
+
*
|
|
6382
|
+
* ```ts
|
|
6383
|
+
* db.$qb
|
|
6384
|
+
* // update record in one table
|
|
6385
|
+
* .with('a', db.table.find(1).select('id').update(data))
|
|
6386
|
+
* // update record in other table using the first table record id
|
|
6387
|
+
* .with('b', (q) =>
|
|
6388
|
+
* db.otherTable
|
|
6389
|
+
* .find(1)
|
|
6390
|
+
* .select('id')
|
|
6391
|
+
* .update({
|
|
6392
|
+
* ...otherData,
|
|
6393
|
+
* aId: () => q.from('a').get('id'),
|
|
6394
|
+
* }),
|
|
6395
|
+
* )
|
|
6396
|
+
* .from('b');
|
|
6397
|
+
* ```
|
|
6398
|
+
*
|
|
6346
6399
|
* ### sub-queries
|
|
6347
6400
|
*
|
|
6348
|
-
* In
|
|
6401
|
+
* In all `create`, `update`, `upsert` methods,
|
|
6402
|
+
* you can use sub queries that are either selecting a single value,
|
|
6403
|
+
* or creating/updating/deleting a record and return a single value.
|
|
6349
6404
|
*
|
|
6350
6405
|
* ```ts
|
|
6351
6406
|
* await db.table.where({ ...conditions }).update({
|
|
@@ -6353,16 +6408,18 @@ declare class Update {
|
|
|
6353
6408
|
* column: () => db.otherTable.get('otherColumn').create({ ...data }),
|
|
6354
6409
|
*
|
|
6355
6410
|
* // `column2` will be set to a value of the `otherColumn` of the updated record.
|
|
6356
|
-
* column2: () =>
|
|
6357
|
-
* .
|
|
6358
|
-
*
|
|
6359
|
-
*
|
|
6411
|
+
* column2: () =>
|
|
6412
|
+
* db.otherTable
|
|
6413
|
+
* .get('otherColumn')
|
|
6414
|
+
* .findBy({ ...conditions })
|
|
6415
|
+
* .update({ key: 'value' }),
|
|
6360
6416
|
*
|
|
6361
6417
|
* // `column3` will be set to a value of the `otherColumn` of the deleted record.
|
|
6362
|
-
* column3: () =>
|
|
6363
|
-
* .
|
|
6364
|
-
*
|
|
6365
|
-
*
|
|
6418
|
+
* column3: () =>
|
|
6419
|
+
* db.otherTable
|
|
6420
|
+
* .get('otherColumn')
|
|
6421
|
+
* .findBy({ ...conditions })
|
|
6422
|
+
* .delete(),
|
|
6366
6423
|
* });
|
|
6367
6424
|
* ```
|
|
6368
6425
|
*
|
|
@@ -6374,47 +6431,25 @@ declare class Update {
|
|
|
6374
6431
|
* VALUES ('val1', 'val2', 'val3')
|
|
6375
6432
|
* RETURNING "otherTable"."selectedColumn"
|
|
6376
6433
|
* )
|
|
6434
|
+
* -- In a case of create
|
|
6435
|
+
* INSERT INTO "table"("column") VALUES ((SELECT * FROM "q"))
|
|
6436
|
+
* -- In a case of update
|
|
6377
6437
|
* UPDATE "table"
|
|
6378
6438
|
* SET "column" = (SELECT * FROM "q")
|
|
6379
6439
|
* ```
|
|
6380
6440
|
*
|
|
6381
|
-
* The query is atomic
|
|
6382
|
-
*
|
|
6383
|
-
* Though it's possible to select a single value from a callback for the column to update:
|
|
6384
|
-
*
|
|
6385
|
-
* ```ts
|
|
6386
|
-
* await db.table.find(1).update({
|
|
6387
|
-
* // update column `one` with the value of column `two` of the related record.
|
|
6388
|
-
* one: (q) => q.relatedTable.get('two'),
|
|
6389
|
-
* })
|
|
6390
|
-
* ```
|
|
6391
|
-
*
|
|
6392
|
-
* It is **not** supported to use `create`, `update`, or `delete` kinds of sub-query on related tables:
|
|
6441
|
+
* The query is atomic.
|
|
6442
|
+
* No changes will persist in the database if the sub-query fails, or if the top-level query fails, or if multiple rows are returned from a sub-query.
|
|
6393
6443
|
*
|
|
6394
|
-
*
|
|
6395
|
-
*
|
|
6396
|
-
* // TS error, this is not allowed:
|
|
6397
|
-
* one: (q) => q.relatedTable.get('two').create({ ...data }),
|
|
6398
|
-
* })
|
|
6399
|
-
* ```
|
|
6444
|
+
* [//]: # 'not supported in create because cannot query related records for a thing that is not created yet'
|
|
6445
|
+
* [//]: # 'modificational sub queries are not allowed in update because it would be too hard to join a with statement to the update query'
|
|
6400
6446
|
*
|
|
6401
|
-
* `update`
|
|
6447
|
+
* Only selective sub-queries are supported in `update` queries when the sub-query is using a relation:
|
|
6402
6448
|
*
|
|
6403
6449
|
* ```ts
|
|
6404
|
-
* db
|
|
6405
|
-
*
|
|
6406
|
-
*
|
|
6407
|
-
* // update record in other table using the first table record id
|
|
6408
|
-
* .with('b', (q) =>
|
|
6409
|
-
* db.otherTable
|
|
6410
|
-
* .find(1)
|
|
6411
|
-
* .select('id')
|
|
6412
|
-
* .update({
|
|
6413
|
-
* ...otherData,
|
|
6414
|
-
* aId: () => q.from('a').get('id'),
|
|
6415
|
-
* }),
|
|
6416
|
-
* )
|
|
6417
|
-
* .from('b');
|
|
6450
|
+
* db.book.update({
|
|
6451
|
+
* authorName: (q) => q.author.get('name'),
|
|
6452
|
+
* });
|
|
6418
6453
|
* ```
|
|
6419
6454
|
*
|
|
6420
6455
|
* ### null, undefined, unknown columns
|
|
@@ -6454,26 +6489,6 @@ declare class Update {
|
|
|
6454
6489
|
* @param arg - data to update records with, may have specific values, raw SQL, queries, or callbacks with sub-queries.
|
|
6455
6490
|
*/
|
|
6456
6491
|
update<T extends UpdateSelf>(this: T, arg: UpdateArg<T>): UpdateResult<T>;
|
|
6457
|
-
/**
|
|
6458
|
-
* `updateSql` is for updating records with raw expression.
|
|
6459
|
-
*
|
|
6460
|
-
* The behavior is the same as a regular `update` method has:
|
|
6461
|
-
* `find` or `where` must precede calling this method,
|
|
6462
|
-
* it returns an updated count by default,
|
|
6463
|
-
* you can customize returning data by using `select`.
|
|
6464
|
-
*
|
|
6465
|
-
* ```ts
|
|
6466
|
-
* const value = 'new name';
|
|
6467
|
-
*
|
|
6468
|
-
* // update with SQL template string
|
|
6469
|
-
* const updatedCount = await db.table.find(1).updateSql`name = ${value}`;
|
|
6470
|
-
*
|
|
6471
|
-
* // or update with `sql` function:
|
|
6472
|
-
* await db.table.find(1).updateSql(sql`name = ${value}`);
|
|
6473
|
-
* ```
|
|
6474
|
-
* @param args - raw SQL via a template string or by using a `sql` method
|
|
6475
|
-
*/
|
|
6476
|
-
updateSql<T extends UpdateSelf>(this: T, ...args: UpdateRawArgs<T>): UpdateResult<T>;
|
|
6477
6492
|
/**
|
|
6478
6493
|
* To make sure that at least one row was updated use `updateOrThrow`:
|
|
6479
6494
|
*
|
|
@@ -6920,6 +6935,14 @@ declare class QueryUpsertOrCreate {
|
|
|
6920
6935
|
* data: {
|
|
6921
6936
|
* // update record's name
|
|
6922
6937
|
* name: 'new name',
|
|
6938
|
+
* // supports sql and nested queries
|
|
6939
|
+
* fromSQL: () => sql`*SQL expression*`,
|
|
6940
|
+
* fromQuery: () => db.someTable.create(data).get('column'),
|
|
6941
|
+
* },
|
|
6942
|
+
* create: {
|
|
6943
|
+
* // create a new record with this email and a name 'new name'
|
|
6944
|
+
* email: 'some@email.com',
|
|
6945
|
+
* // supports sql and nested queries as well
|
|
6923
6946
|
* },
|
|
6924
6947
|
* create: {
|
|
6925
6948
|
* // create a new record with this email and a name 'new name'
|
|
@@ -7010,11 +7033,16 @@ declare class QueryUpsertOrCreate {
|
|
|
7010
7033
|
* No result is returned by default, place `get`, `select`, or `selectAll` before `orCreate` to specify returning columns.
|
|
7011
7034
|
*
|
|
7012
7035
|
* ```ts
|
|
7013
|
-
* const user = await
|
|
7036
|
+
* const user = await db.user
|
|
7037
|
+
* .selectAll()
|
|
7014
7038
|
* .findBy({ email: 'some@email.com' })
|
|
7015
7039
|
* .orCreate({
|
|
7016
7040
|
* email: 'some@email.com',
|
|
7017
7041
|
* name: 'created user',
|
|
7042
|
+
* // supports sql and nested queries
|
|
7043
|
+
* fromSQL: () => sql`*SQL expression*`,
|
|
7044
|
+
* fromQuery: () => db.someTable.create(data).get('column'),
|
|
7045
|
+
* fromRelated: (q) => q.relatedTable.update(data).get('column'),
|
|
7018
7046
|
* });
|
|
7019
7047
|
* ```
|
|
7020
7048
|
*
|
|
@@ -7971,7 +7999,7 @@ interface Query extends QueryMethods<unknown> {
|
|
|
7971
7999
|
internal: QueryInternal;
|
|
7972
8000
|
meta: QueryMetaBase<EmptyObject>;
|
|
7973
8001
|
returnType: QueryReturnType;
|
|
7974
|
-
|
|
8002
|
+
qb: QueryBuilder;
|
|
7975
8003
|
columnTypes: unknown;
|
|
7976
8004
|
shape: QueryColumns;
|
|
7977
8005
|
inputType: RecordUnknown;
|
|
@@ -8788,10 +8816,7 @@ declare const setColumnParseNull: (column: ColumnTypeBase, fn: () => unknown, nu
|
|
|
8788
8816
|
declare const setColumnEncode: (column: ColumnTypeBase, fn: (input: any) => unknown, inputSchema?: unknown) => any;
|
|
8789
8817
|
declare const getColumnBaseType: (column: ColumnTypeBase, domainsMap: DbStructureDomainsMap, type: string) => string;
|
|
8790
8818
|
|
|
8791
|
-
|
|
8792
|
-
declare const escapeForLog: (value: Value) => string;
|
|
8793
|
-
declare const escapeForMigration: (value: Value) => string;
|
|
8794
|
-
declare const escapeString: (value: string) => string;
|
|
8819
|
+
declare const anyShape: QueryColumnsInit;
|
|
8795
8820
|
|
|
8796
8821
|
/**
|
|
8797
8822
|
* Call `.clone()` on a supposed query object
|
|
@@ -8833,7 +8858,7 @@ declare const setQueryObjectValueImmutable: <T extends PickQueryQ>(q: T, object:
|
|
|
8833
8858
|
*/
|
|
8834
8859
|
declare const throwIfNoWhere: (q: PickQueryQ, method: string) => void;
|
|
8835
8860
|
declare const throwIfJoinLateral: (q: PickQueryQ, method: string) => void;
|
|
8836
|
-
declare const
|
|
8861
|
+
declare const saveAliasedShape: (q: IsQuery, as: string, key: 'joinedShapes' | 'withShapes') => string;
|
|
8837
8862
|
/**
|
|
8838
8863
|
* Extend query prototype with new methods.
|
|
8839
8864
|
* The query and its data are cloned (with Object.create).
|
|
@@ -8850,8 +8875,13 @@ declare const _queryExec: <T extends IsQuery>(q: T) => never;
|
|
|
8850
8875
|
declare const _queryRows: <T extends PickQueryResult>(q: T) => SetQueryReturnsRows<T>;
|
|
8851
8876
|
declare const getFullColumnTable: (q: IsQuery, column: string, index: number, as: string | getValueKey | undefined) => string;
|
|
8852
8877
|
|
|
8878
|
+
type Value = any;
|
|
8879
|
+
declare const escapeForLog: (value: Value) => string;
|
|
8880
|
+
declare const escapeForMigration: (value: Value) => string;
|
|
8881
|
+
declare const escapeString: (value: string) => string;
|
|
8882
|
+
|
|
8853
8883
|
type Arg = {
|
|
8854
|
-
$
|
|
8884
|
+
$qb: Query;
|
|
8855
8885
|
} | Query;
|
|
8856
8886
|
declare const testTransaction: {
|
|
8857
8887
|
/**
|
|
@@ -8972,4 +9002,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
|
|
|
8972
9002
|
*/
|
|
8973
9003
|
declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
|
|
8974
9004
|
|
|
8975
|
-
export { Adapter, type AdapterConfig, type AdapterOptions, type AddQueryDefaults, AfterCommitError, type AfterCommitErrorFulfilledResult, type AfterCommitErrorHandler, type AfterCommitErrorRejectedResult, type AfterCommitErrorResult, type AfterHook, type AggregateArgTypes, AggregateMethods, type AggregateOptions, type AliasOrTable, ArrayColumn, type ArrayColumnValue, type ArrayData, AsMethods, type AsQueryArg, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, type BooleanQueryColumn, BoxColumn, ByteaColumn, type ChangeCountArg, CidrColumn, CircleColumn, CitextColumn, Clear, type ClearStatement, type ColumnData, type ColumnDataGenerated, type ColumnFromDbParams, type ColumnInfoQueryData, ColumnRefExpression, ColumnType, type ColumnsByType, type ColumnsShape, type ColumnsShapeToNullableObject, type ColumnsShapeToObject, type ColumnsShapeToObjectArray, type ColumnsShapeToPluck, type CommonQueryData, ComputedColumn, type ComputedColumns, type ComputedColumnsFromOptions, type ComputedMethods, type ComputedOptionsConfig, type ComputedOptionsFactory, type CopyOptions, type CopyQueryData, Create, type CreateBelongsToData, type CreateColumn, type CreateCtx, type CreateData, type CreateKind, type CreateMethodsNames, type CreateRelationsData, type CreateRelationsDataOmittingFKeys, type CreateResult, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbDomainArgRecord, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbStructureDomainsMap, type DbTableConstructor, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultSchemaConfig, Delete, type DeleteArgs, type DeleteMethodsNames, type DeleteQueryData, type DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, type ExpressionOutput, FnExpression, type FnExpressionArgs, type FnExpressionArgsPairs, type FnExpressionArgsValue, For, type FromArg, FromMethods, type FromQuerySelf, type FromResult, type GeneratedColumn, type GeneratorIgnore, type GetArg, type GetColumnInfo, type GetResult, type GetResultOptional, type GetStringArg, type GroupArgs, type HandleResult, Having, type HavingItem, type HookAction, type HookSelectArg, type IdentityColumn, InetColumn, type InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsolationLevel, JSONColumn, JSONTextColumn, Join, type JoinArgToQuery, type JoinArgs, type JoinCallback, type JoinFirstArg, type JoinItem, type JoinItemArgs, type JoinLateralResult, type JoinQueryBuilder, type JoinQueryMethod, type JoinResult, type JoinResultRequireMain, type JoinedParsers, type JoinedShapes, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, type NumericColumns, type OnConflictMerge, OnConflictQueryBuilder, type OnConflictSet, type OnConflictTarget, OnMethods, type Operator, Operators, type OperatorsAny, type OperatorsArray, type OperatorsBoolean, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsText, type OperatorsTime, type OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, type OrderArg, type OrderArgSelf, type OrderArgs, type OrderItem, type OrderTsQueryConfig, type Over, PathColumn, type PickColumnData, type PickQueryBaseQuery, type PickQueryColumnTypes, type PickQueryDataShapeAndJoinedShapes, type PickQueryDataShapeAndJoinedShapesAndAliases, type PickQueryInternal, type PickQueryMetaColumnTypes, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaRelationsResultReturnType, type PickQueryMetaRelationsReturnType, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsThen, type PickQueryMetaShapeRelationsReturnType, type PickQueryMetaShapeRelationsWithData, type PickQueryMetaTable, type PickQueryMetaTableShape, type PickQueryMetaTableShapeReturnTypeWithData, type PickQueryMetaWithData, type PickQueryMetaWithDataColumnTypes, type PickQueryQ, type PickQueryQAndBaseQuery, type PickQueryQAndInternal, type PickQueryRelationQueries, type PickQueryRelations, type PickQueryRelationsWithData, type PickQueryResultColumnTypes, type PickQueryShapeResultReturnTypeSinglePrimaryKey, type PickQueryShapeResultSinglePrimaryKey, type PickQueryShapeSinglePrimaryKey, type PickQuerySinglePrimaryKey, type PickQueryTableMetaResultReturnTypeWithDataWindowsThen, type PickQueryWindows, type PickQueryWithData, type PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type PostgisPoint, type Queries, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBatchResult, type QueryBeforeHook, type QueryComputedArg, type QueryData, type QueryDataFromItem, type QueryDataJoinTo, type QueryDefaultReturnData, QueryError, type QueryErrorName, QueryGet, type QueryGetSelf, type QueryHelperResult, QueryHooks, type QueryIfResultThen, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, type QueryTake, type QueryTakeOptional, QueryUpsertOrCreate, RawSQL, RealColumn, type RecordOfColumnsShapeBase, RefExpression, type RelationConfigBase, type RelationConfigDataForCreate, type RelationConfigQuery, type RelationJoinQuery, type RelationsBase, type ReturnsQueryOrExpression, type RuntimeComputedQueryColumn, type SearchArg, SearchMethods, type SearchWeight, type SearchWeightRecord, Select, type SelectArg, type SelectArgs, type SelectAs, type SelectAsValue, type SelectItem, type SelectQueryData, type SelectSubQueryResult, type SelectableFromShape, type SelectableOfType, type SelectableOrExpression, type SelectableOrExpressionOfType, type SelectableOrExpressions, SerialColumn, type SerialColumnData, type SetQueryKind, type SetQueryKindResult, type SetQueryReturnsAll, type SetQueryReturnsAllKind, type SetQueryReturnsAllKindResult, type SetQueryReturnsColumnInfo, type SetQueryReturnsColumnKind, type SetQueryReturnsColumnKindResult, type SetQueryReturnsColumnOptional, type SetQueryReturnsColumnOrThrow, type SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, type SetQueryReturnsPluck, type SetQueryReturnsPluckColumn, type SetQueryReturnsPluckColumnKind, type SetQueryReturnsPluckColumnKindResult, type SetQueryReturnsRowCount, type SetQueryReturnsRowCountMany, type SetQueryReturnsRows, type SetQueryReturnsValueOptional, type SetQueryReturnsValueOrThrow, type SetQueryReturnsVoid, type SetQueryReturnsVoidKind, type SetQueryTableAlias, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, type SortDir, type SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, TextBaseColumn, TextColumn, type TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, type ToSQLCtx, type ToSQLOptions, type ToSQLQuery, Transaction, TransactionAdapter, type TransactionOptions, TransformMethods, type TruncateQueryData, TsQueryColumn, TsVectorColumn, type TypeParsers, UUIDColumn, UnhandledTypeError, Union, type UnionArgs, type UnionItem, type UnionKind, type UnionSet, type UniqueConstraints, type UniqueQueryTypeOrExpression, type UniqueTableDataItem, UnknownColumn, Update, type UpdateArg, type UpdateCtx, type UpdateCtxCollect, type UpdateData, type UpdateQueryData, type UpdateQueryDataItem, type UpdateQueryDataObject, type UpdateSelf, type UpdatedAtDataInjector, type UpsertResult, type UpsertThis, VarCharColumn, VirtualColumn, Where, type WhereArg, type WhereArgs, type WhereInArg, type WhereInColumn, type WhereInItem, type WhereInValues, type WhereItem, type WhereJsonPathEqualsItem, type WhereNotArgs, type WhereOnItem, type WhereOnJoinItem, type WhereQueryBuilder, type WhereResult, type WhereSearchItem, type WhereSearchResult, type WindowArg, type WindowArgDeclaration, type WindowDeclaration, type WindowItem, type WithArgsOptions, type WithConfigs, type WithDataItem, type WithDataItems, type WithItem, WithMethods, type WithOptions, type WithQueryBuilder, type WithRecursiveOptions, type WithResult, type WithSqlResult, type WrapQueryArg, XMLColumn, _clone, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, _runAfterCommitHooks, addColumnParserToQuery, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, assignDbDataToColumn, checkIfASimpleQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFullColumnTable, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, isDefaultTimeStamp, isInUserTransaction, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArrayImmutable, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValueImmutable, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallbackV2, rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValueImmutable, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL };
|
|
9005
|
+
export { Adapter, type AdapterConfig, type AdapterOptions, type AddQueryDefaults, AfterCommitError, type AfterCommitErrorFulfilledResult, type AfterCommitErrorHandler, type AfterCommitErrorRejectedResult, type AfterCommitErrorResult, type AfterHook, type AggregateArgTypes, AggregateMethods, type AggregateOptions, type AliasOrTable, ArrayColumn, type ArrayColumnValue, type ArrayData, AsMethods, type AsQueryArg, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, type BooleanQueryColumn, BoxColumn, ByteaColumn, type ChangeCountArg, CidrColumn, CircleColumn, CitextColumn, Clear, type ClearStatement, type ColumnData, type ColumnDataGenerated, type ColumnFromDbParams, type ColumnInfoQueryData, ColumnRefExpression, ColumnType, type ColumnsByType, type ColumnsShape, type ColumnsShapeToNullableObject, type ColumnsShapeToObject, type ColumnsShapeToObjectArray, type ColumnsShapeToPluck, type CommonQueryData, ComputedColumn, type ComputedColumns, type ComputedColumnsFromOptions, type ComputedMethods, type ComputedOptionsConfig, type ComputedOptionsFactory, type CopyOptions, type CopyQueryData, Create, type CreateBelongsToData, type CreateColumn, type CreateCtx, type CreateData, type CreateKind, type CreateMethodsNames, type CreateRelationsData, type CreateRelationsDataOmittingFKeys, type CreateResult, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbDomainArgRecord, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlQuery, type DbStructureDomainsMap, type DbTableConstructor, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultSchemaConfig, Delete, type DeleteArgs, type DeleteMethodsNames, type DeleteQueryData, type DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, type ExpressionOutput, FnExpression, type FnExpressionArgs, type FnExpressionArgsPairs, type FnExpressionArgsValue, For, type FromArg, FromMethods, type FromQuerySelf, type FromResult, type GeneratedColumn, type GeneratorIgnore, type GetArg, type GetColumnInfo, type GetResult, type GetResultOptional, type GetStringArg, type GroupArgs, type HandleResult, Having, type HavingItem, type HookAction, type HookSelectArg, type IdentityColumn, InetColumn, type InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsolationLevel, JSONColumn, JSONTextColumn, Join, type JoinArgToQuery, type JoinArgs, type JoinCallback, type JoinFirstArg, type JoinItem, type JoinItemArgs, type JoinLateralResult, type JoinQueryBuilder, type JoinQueryMethod, type JoinResult, type JoinResultRequireMain, type JoinedParsers, type JoinedShapes, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, type NumericColumns, type OnConflictMerge, OnConflictQueryBuilder, type OnConflictSet$1 as OnConflictSet, type OnConflictTarget, OnMethods, type Operator, Operators, type OperatorsAny, type OperatorsArray, type OperatorsBoolean, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsText, type OperatorsTime, type OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, type OrderArg, type OrderArgSelf, type OrderArgs, type OrderItem, type OrderTsQueryConfig, type Over, PathColumn, type PickColumnData, type PickQueryBaseQuery, type PickQueryColumnTypes, type PickQueryDataShapeAndJoinedShapes, type PickQueryDataShapeAndJoinedShapesAndAliases, type PickQueryInternal, type PickQueryMetaColumnTypes, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaRelationsResultReturnType, type PickQueryMetaRelationsReturnType, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsThen, type PickQueryMetaShapeRelationsReturnType, type PickQueryMetaShapeRelationsWithData, type PickQueryMetaTable, type PickQueryMetaTableShape, type PickQueryMetaTableShapeReturnTypeWithData, type PickQueryMetaWithData, type PickQueryMetaWithDataColumnTypes, type PickQueryQ, type PickQueryQAndBaseQuery, type PickQueryQAndInternal, type PickQueryRelationQueries, type PickQueryRelations, type PickQueryRelationsWithData, type PickQueryResultColumnTypes, type PickQueryShapeResultReturnTypeSinglePrimaryKey, type PickQueryShapeResultSinglePrimaryKey, type PickQueryShapeSinglePrimaryKey, type PickQuerySinglePrimaryKey, type PickQueryTableMetaResultReturnTypeWithDataWindowsThen, type PickQueryWindows, type PickQueryWithData, type PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type PostgisPoint, type Queries, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBatchResult, type QueryBeforeHook, type QueryBuilder, type QueryComputedArg, type QueryData, type QueryDataFromItem, type QueryDataJoinTo, type QueryDefaultReturnData, QueryError, type QueryErrorName, QueryGet, type QueryGetSelf, type QueryHelperResult, QueryHooks, type QueryIfResultThen, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, type QueryTake, type QueryTakeOptional, QueryUpsertOrCreate, RawSQL, RealColumn, type RecordOfColumnsShapeBase, RefExpression, type RelationConfigBase, type RelationConfigDataForCreate, type RelationConfigQuery, type RelationJoinQuery, type RelationsBase, type ReturnsQueryOrExpression, type RuntimeComputedQueryColumn, type SearchArg, SearchMethods, type SearchWeight, type SearchWeightRecord, Select, type SelectArg, type SelectArgs, type SelectAs, type SelectAsValue, type SelectItem, type SelectQueryData, type SelectSubQueryResult, type SelectableFromShape, type SelectableOfType, type SelectableOrExpression, type SelectableOrExpressionOfType, type SelectableOrExpressions, SerialColumn, type SerialColumnData, type SetQueryKind, type SetQueryKindResult, type SetQueryReturnsAll, type SetQueryReturnsAllKind, type SetQueryReturnsAllKindResult, type SetQueryReturnsColumnInfo, type SetQueryReturnsColumnKind, type SetQueryReturnsColumnKindResult, type SetQueryReturnsColumnOptional, type SetQueryReturnsColumnOrThrow, type SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, type SetQueryReturnsPluck, type SetQueryReturnsPluckColumn, type SetQueryReturnsPluckColumnKind, type SetQueryReturnsPluckColumnKindResult, type SetQueryReturnsRowCount, type SetQueryReturnsRowCountMany, type SetQueryReturnsRows, type SetQueryReturnsValueOptional, type SetQueryReturnsValueOrThrow, type SetQueryReturnsVoid, type SetQueryReturnsVoidKind, type SetQueryTableAlias, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, type SortDir, type SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, TextBaseColumn, TextColumn, type TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, type ToSQLCtx, type ToSQLOptions, type ToSQLQuery, Transaction, TransactionAdapter, type TransactionOptions, TransformMethods, type TruncateQueryData, TsQueryColumn, TsVectorColumn, type TypeParsers, UUIDColumn, UnhandledTypeError, Union, type UnionArgs, type UnionItem, type UnionKind, type UnionSet, type UniqueConstraints, type UniqueQueryTypeOrExpression, type UniqueTableDataItem, UnknownColumn, Update, type UpdateArg, type UpdateCtx, type UpdateCtxCollect, type UpdateData, type UpdateQueryData, type UpdateQueryDataItem, type UpdateQueryDataObject, type UpdateSelf, type UpdatedAtDataInjector, type UpsertResult, type UpsertThis, VarCharColumn, VirtualColumn, Where, type WhereArg, type WhereArgs, type WhereInArg, type WhereInColumn, type WhereInItem, type WhereInValues, type WhereItem, type WhereJsonPathEqualsItem, type WhereNotArgs, type WhereOnItem, type WhereOnJoinItem, type WhereQueryBuilder, type WhereResult, type WhereSearchItem, type WhereSearchResult, type WindowArg, type WindowArgDeclaration, type WindowDeclaration, type WindowItem, type WithArgsOptions, type WithConfigs, type WithDataItem, type WithDataItems, type WithItem, type WithItems, WithMethods, type WithOptions, type WithQueryBuilder, type WithRecursiveOptions, type WithResult, type WithSqlResult, type WrapQueryArg, XMLColumn, _clone, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, _runAfterCommitHooks, addColumnParserToQuery, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, assignDbDataToColumn, checkIfASimpleQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFullColumnTable, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, isDefaultTimeStamp, isInUserTransaction, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, moveQueryValueToWith, parseRecord, parseTableData, parseTableDataInput, performQuery, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArrayImmutable, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValueImmutable, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallbackV2, rollbackSql, saveAliasedShape, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValueImmutable, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL };
|