pqb 0.31.9 → 0.33.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 +233 -284
- package/dist/index.js +80 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -245
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as orchid_core from 'orchid-core';
|
|
2
|
-
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, RecordUnknown, RecordKeyTrue, EmptyObject, QueryBaseCommon, QueryColumns, QueryMetaBase, QueryReturnType, QueryThen, Expression,
|
|
2
|
+
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, RecordUnknown, RecordKeyTrue, EmptyObject, QueryBaseCommon, QueryColumns, QueryMetaBase, QueryReturnType, QueryThen, Expression, MaybeArray, SelectableBase, TemplateLiteralArgs, ColumnsShapeBase, ColumnsParsers, RecordString, PickQueryTable, FnUnknownToUnknown, ExpressionChain, getValueKey, QueryColumn, PickQueryShape, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, PickQueryResult, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, ExpressionData, ValExpression, PickOutputType, SQLQueryArgs, ColumnSchemaConfig, DateColumnData, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, StaticSQLArgs, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ParseColumn, EncodeColumn, PickQueryMetaResult, QueryColumnsInit, DefaultSelectColumns, CoreQueryScopes, DbBase, QueryCatch, TransactionState, ColumnTypeBase, PickQueryUniqueProperties, IsQuery, PickQueryTableMetaResultInputType, SingleSql, MergeObjects, PickQueryResultUniqueColumns, QueryInternalBase, PickQueryReturnType, PickType, ColumnShapeOutput, OperatorsNullable, PickQueryMetaReturnType, UniqueColumn, TimestampHelpers, Codes, ColumnDataCheckBase, PickQueryTableMetaShape } from 'orchid-core';
|
|
3
3
|
import { PoolConfig, Pool, PoolClient } from 'pg';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -119,46 +119,7 @@ interface WithOptions {
|
|
|
119
119
|
materialized?: true;
|
|
120
120
|
notMaterialized?: true;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
__json: [
|
|
124
|
-
kind: 'set',
|
|
125
|
-
as: As,
|
|
126
|
-
type: Type,
|
|
127
|
-
column: string | JsonItem,
|
|
128
|
-
path: Array<string | number>,
|
|
129
|
-
value: unknown,
|
|
130
|
-
options?: {
|
|
131
|
-
createIfMissing?: boolean;
|
|
132
|
-
}
|
|
133
|
-
] | [
|
|
134
|
-
kind: 'insert',
|
|
135
|
-
as: As,
|
|
136
|
-
type: Type,
|
|
137
|
-
column: string | JsonItem,
|
|
138
|
-
path: Array<string | number>,
|
|
139
|
-
value: unknown,
|
|
140
|
-
options?: {
|
|
141
|
-
insertAfter?: boolean;
|
|
142
|
-
}
|
|
143
|
-
] | [
|
|
144
|
-
kind: 'remove',
|
|
145
|
-
as: As,
|
|
146
|
-
type: Type,
|
|
147
|
-
column: string | JsonItem,
|
|
148
|
-
path: Array<string | number>
|
|
149
|
-
] | [
|
|
150
|
-
kind: 'pathQuery',
|
|
151
|
-
as: As,
|
|
152
|
-
type: Type,
|
|
153
|
-
column: string | JsonItem,
|
|
154
|
-
path: string,
|
|
155
|
-
options?: {
|
|
156
|
-
vars?: string;
|
|
157
|
-
silent?: boolean;
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
|
-
}
|
|
161
|
-
type SelectItem = string | SelectAs | JsonItem | Expression;
|
|
122
|
+
type SelectItem = string | SelectAs | Expression;
|
|
162
123
|
interface SelectAs {
|
|
163
124
|
selectAs: SelectAsValue$1;
|
|
164
125
|
}
|
|
@@ -307,76 +268,6 @@ type OnConflictMerge = string | string[] | {
|
|
|
307
268
|
except: string | string[];
|
|
308
269
|
};
|
|
309
270
|
|
|
310
|
-
interface Operator<Value, Column extends PickOutputTypeAndOperators = PickOutputTypeAndOperators> {
|
|
311
|
-
<T extends PickQueryResult>(this: T, arg: Value): Omit<SetQueryReturnsColumnOrThrow<T, Column>, keyof T['result']['value']['operators']> & Column['operators'];
|
|
312
|
-
_opType: Value;
|
|
313
|
-
_op: OperatorToSQL<any, ToSQLCtx>;
|
|
314
|
-
}
|
|
315
|
-
interface BaseOperators {
|
|
316
|
-
[K: string]: Operator<any>;
|
|
317
|
-
}
|
|
318
|
-
declare function setQueryOperators(query: PickQueryBaseQuery, operators: BaseOperators): PickQueryBaseQuery;
|
|
319
|
-
type Base<Value> = {
|
|
320
|
-
equals: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
321
|
-
not: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
322
|
-
in: Operator<Value[] | Query | Expression, BooleanQueryColumn>;
|
|
323
|
-
notIn: Operator<Value[] | Query | Expression, BooleanQueryColumn>;
|
|
324
|
-
};
|
|
325
|
-
type OperatorsBoolean = Base<boolean> & {
|
|
326
|
-
and: Operator<{
|
|
327
|
-
result: {
|
|
328
|
-
value: BooleanQueryColumn;
|
|
329
|
-
};
|
|
330
|
-
} & OperatorsBoolean, BooleanQueryColumn>;
|
|
331
|
-
or: Operator<{
|
|
332
|
-
result: {
|
|
333
|
-
value: BooleanQueryColumn;
|
|
334
|
-
};
|
|
335
|
-
} & OperatorsBoolean, BooleanQueryColumn>;
|
|
336
|
-
};
|
|
337
|
-
type Ord<Value> = Base<Value> & {
|
|
338
|
-
lt: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
339
|
-
lte: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
340
|
-
gt: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
341
|
-
gte: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
342
|
-
between: Operator<[
|
|
343
|
-
Value | Query | Expression,
|
|
344
|
-
Value | Query | Expression
|
|
345
|
-
], BooleanQueryColumn>;
|
|
346
|
-
};
|
|
347
|
-
type OperatorsNumber = Ord<number>;
|
|
348
|
-
type OperatorsText = Base<string> & {
|
|
349
|
-
contains: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
350
|
-
containsSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
351
|
-
startsWith: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
352
|
-
startsWithSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
353
|
-
endsWith: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
354
|
-
endsWithSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
355
|
-
};
|
|
356
|
-
type OperatorsJson = Base<unknown> & {
|
|
357
|
-
jsonPath: Operator<[
|
|
358
|
-
path: string,
|
|
359
|
-
op: string,
|
|
360
|
-
value: unknown | Query | Expression
|
|
361
|
-
], BooleanQueryColumn>;
|
|
362
|
-
jsonSupersetOf: Operator<unknown | Query | Expression, BooleanQueryColumn>;
|
|
363
|
-
jsonSubsetOf: Operator<unknown | Query | Expression, BooleanQueryColumn>;
|
|
364
|
-
};
|
|
365
|
-
type OperatorsAny = Base<any>;
|
|
366
|
-
type OperatorsDate = Ord<Date | string>;
|
|
367
|
-
type OperatorsArray = Base<any>;
|
|
368
|
-
type OperatorsTime = Ord<string>;
|
|
369
|
-
declare const Operators: {
|
|
370
|
-
any: OperatorsAny;
|
|
371
|
-
boolean: OperatorsBoolean;
|
|
372
|
-
number: OperatorsNumber;
|
|
373
|
-
date: OperatorsDate;
|
|
374
|
-
time: OperatorsTime;
|
|
375
|
-
text: OperatorsText;
|
|
376
|
-
json: OperatorsJson;
|
|
377
|
-
array: OperatorsArray;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
271
|
interface RecordOfColumnsShapeBase {
|
|
381
272
|
[K: string]: ColumnsShapeBase;
|
|
382
273
|
}
|
|
@@ -448,13 +339,13 @@ interface CommonQueryData {
|
|
|
448
339
|
[toSQLCacheKey]?: Sql;
|
|
449
340
|
transform?: FnUnknownToUnknown[];
|
|
450
341
|
language?: string;
|
|
451
|
-
|
|
342
|
+
subQuery?: number;
|
|
452
343
|
relChain?: (Query | RelationQuery)[];
|
|
453
344
|
/**
|
|
454
345
|
* Stores current operator functions available for the query.
|
|
455
346
|
* Is needed to remove these operators from query object when changing the query type, see {@link setQueryOperators}.
|
|
456
347
|
*/
|
|
457
|
-
operators?:
|
|
348
|
+
operators?: RecordUnknown;
|
|
458
349
|
scopes?: {
|
|
459
350
|
[K: string]: QueryScopeData;
|
|
460
351
|
};
|
|
@@ -1472,11 +1363,217 @@ declare class FnExpression<Q extends Query = Query, T extends QueryColumn = Quer
|
|
|
1472
1363
|
constructor(query: Q, fn: string, args: FnExpressionArgs<Q>, options: AggregateOptions<Q>, value: T);
|
|
1473
1364
|
makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
|
|
1474
1365
|
}
|
|
1475
|
-
type ColumnExpression<C extends QueryColumn, Ops extends BaseOperators = C['operators']> = Expression<C> & {
|
|
1476
|
-
[K in keyof Ops]: (arg: Ops[K]['_opType']) => ColumnExpression<QueryColumnBooleanOrNull>;
|
|
1477
|
-
};
|
|
1478
1366
|
declare function makeFnExpression<T extends PickQueryMetaResultRelationsWindows, C extends QueryColumn>(self: T, type: C, fn: string, args: FnExpressionArgs<Query>, options?: AggregateOptions<T>): SetQueryReturnsColumnOrThrow<T, C> & C['operators'];
|
|
1479
1367
|
|
|
1368
|
+
interface Operator<Value, Column extends PickOutputTypeAndOperators = PickOutputTypeAndOperators> {
|
|
1369
|
+
<T extends PickQueryResult>(this: T, arg: Value): Omit<SetQueryReturnsColumnOrThrow<T, Column>, keyof T['result']['value']['operators']> & Column['operators'];
|
|
1370
|
+
_opType: Value;
|
|
1371
|
+
}
|
|
1372
|
+
declare function setQueryOperators(query: PickQueryBaseQuery, operators: RecordUnknown): PickQueryBaseQuery;
|
|
1373
|
+
interface Base<Value> {
|
|
1374
|
+
equals: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1375
|
+
not: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1376
|
+
in: Operator<Value[] | Query | Expression, BooleanQueryColumn>;
|
|
1377
|
+
notIn: Operator<Value[] | Query | Expression, BooleanQueryColumn>;
|
|
1378
|
+
}
|
|
1379
|
+
interface OperatorsBooleanSelf extends OperatorsBoolean {
|
|
1380
|
+
result: {
|
|
1381
|
+
value: BooleanQueryColumn;
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
interface OperatorsBoolean extends Base<boolean> {
|
|
1385
|
+
and: Operator<OperatorsBooleanSelf, BooleanQueryColumn>;
|
|
1386
|
+
or: Operator<OperatorsBooleanSelf, BooleanQueryColumn>;
|
|
1387
|
+
}
|
|
1388
|
+
interface Ord<Value> extends Base<Value> {
|
|
1389
|
+
lt: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1390
|
+
lte: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1391
|
+
gt: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1392
|
+
gte: Operator<Value | Query | Expression, BooleanQueryColumn>;
|
|
1393
|
+
between: Operator<[
|
|
1394
|
+
Value | Query | Expression,
|
|
1395
|
+
Value | Query | Expression
|
|
1396
|
+
], BooleanQueryColumn>;
|
|
1397
|
+
}
|
|
1398
|
+
type OperatorsNumber = Ord<number>;
|
|
1399
|
+
interface OperatorsText extends Base<string> {
|
|
1400
|
+
contains: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1401
|
+
containsSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1402
|
+
startsWith: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1403
|
+
startsWithSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1404
|
+
endsWith: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1405
|
+
endsWithSensitive: Operator<string | Query | Expression, BooleanQueryColumn>;
|
|
1406
|
+
}
|
|
1407
|
+
interface JsonPathQueryOptions {
|
|
1408
|
+
vars?: RecordUnknown;
|
|
1409
|
+
silent?: boolean;
|
|
1410
|
+
}
|
|
1411
|
+
interface JsonPathQueryTypeOptions<T extends PickQueryColumnTypes, C extends QueryColumn> extends JsonPathQueryOptions {
|
|
1412
|
+
type?: (types: T['columnTypes']) => C;
|
|
1413
|
+
}
|
|
1414
|
+
interface JsonPathQuery {
|
|
1415
|
+
/**
|
|
1416
|
+
* Selects a value from JSON data using a JSON path.
|
|
1417
|
+
*
|
|
1418
|
+
* Calls the [jsonb_path_query_first](https://www.postgresql.org/docs/current/functions-json.html) Postgres function.
|
|
1419
|
+
*
|
|
1420
|
+
* Type can be provided via `{ type: (t) => t.columnType() }` options, by default the type is `unknown`.
|
|
1421
|
+
*
|
|
1422
|
+
* Optionally takes `vars` and `silent` parameters, see [Postgres docs](https://www.postgresql.org/docs/current/functions-json.html) for details.
|
|
1423
|
+
*
|
|
1424
|
+
* ```ts
|
|
1425
|
+
* // query a single value from a JSON data,
|
|
1426
|
+
* // because of the provided type, string JSON value will be parsed to a Date object.
|
|
1427
|
+
* const value = await db.table
|
|
1428
|
+
* .get('data')
|
|
1429
|
+
* .jsonPathQueryFirst('$.path.to.date', { type: (t) => t.date().asDate() });
|
|
1430
|
+
*
|
|
1431
|
+
* // using it in a select
|
|
1432
|
+
* const records = await db.table.select({
|
|
1433
|
+
* date: (q) =>
|
|
1434
|
+
* q.get('data').jsonPathQueryFirst('$[*] ? (@ = key)', {
|
|
1435
|
+
* type: (t) => t.integer(),
|
|
1436
|
+
* // defining `vars` and `silent`
|
|
1437
|
+
* vars: { key: 'key' },
|
|
1438
|
+
* silent: true,
|
|
1439
|
+
* }),
|
|
1440
|
+
* });
|
|
1441
|
+
*
|
|
1442
|
+
* // using it in `where`
|
|
1443
|
+
* const filtered = await db.table.where((q) =>
|
|
1444
|
+
* // filtering records by the `name` property from the `data` JSON column
|
|
1445
|
+
* q.get('data').jsonPathQueryFirst('$.name').equals('name'),
|
|
1446
|
+
* );
|
|
1447
|
+
*
|
|
1448
|
+
* // using it in update
|
|
1449
|
+
* await db.table.find(id).update({
|
|
1450
|
+
* // using data property to set the `name` column
|
|
1451
|
+
* name: (q) =>
|
|
1452
|
+
* q.get('data').jsonPathQueryFirst('$.name', { type: (t) => t.string() }),
|
|
1453
|
+
* });
|
|
1454
|
+
* ```
|
|
1455
|
+
*
|
|
1456
|
+
* @param path - JSON path
|
|
1457
|
+
* @param options - can have type, vars, silent
|
|
1458
|
+
*/
|
|
1459
|
+
<T extends PickQueryResultColumnTypes, C extends QueryColumn = QueryColumn<unknown, OperatorsAny>>(this: T, path: string, options?: JsonPathQueryTypeOptions<T, C>): Omit<SetQueryReturnsColumnOrThrow<T, C>, keyof T['result']['value']['operators']> & C['operators'];
|
|
1460
|
+
_opType: never;
|
|
1461
|
+
}
|
|
1462
|
+
interface OperatorsJson extends Base<unknown> {
|
|
1463
|
+
jsonPathQueryFirst: JsonPathQuery;
|
|
1464
|
+
jsonSupersetOf: Operator<unknown | Query | Expression, BooleanQueryColumn>;
|
|
1465
|
+
jsonSubsetOf: Operator<unknown | Query | Expression, BooleanQueryColumn>;
|
|
1466
|
+
jsonSet: {
|
|
1467
|
+
/**
|
|
1468
|
+
* Returns a JSON value/object/array where a given value is set at the given path.
|
|
1469
|
+
* The path is a key or an array of keys to access the value.
|
|
1470
|
+
*
|
|
1471
|
+
* Calls the [jsonb_set](https://www.postgresql.org/docs/current/functions-json.html) Postgres function.
|
|
1472
|
+
*
|
|
1473
|
+
* It can be used in all contexts on a single JSON value.
|
|
1474
|
+
*
|
|
1475
|
+
* ```ts
|
|
1476
|
+
* await db.table.find(id).update({
|
|
1477
|
+
* data: (q) => q.get('data').jsonSet(['path', 'to', 'value'], 'new value'),
|
|
1478
|
+
* });
|
|
1479
|
+
* ```
|
|
1480
|
+
*
|
|
1481
|
+
* @param path - key or array of keys
|
|
1482
|
+
* @param value - value to set
|
|
1483
|
+
*/
|
|
1484
|
+
<T extends PickQueryResult>(this: T, path: MaybeArray<string | number>, value: unknown): T;
|
|
1485
|
+
_opType: never;
|
|
1486
|
+
};
|
|
1487
|
+
jsonReplace: {
|
|
1488
|
+
/**
|
|
1489
|
+
* The same as {@link jsonSet}, but sets the last argument of `jsonb_set` to false,
|
|
1490
|
+
* so this function only has effect when the value already existed in the JSON.
|
|
1491
|
+
*
|
|
1492
|
+
* ```ts
|
|
1493
|
+
* await db.table.find(id).update({
|
|
1494
|
+
* // data.path.to.value will be updated only if it already was defined
|
|
1495
|
+
* data: (q) => q.get('data').jsonReplace(['path', 'to', 'value'], 'new value'),
|
|
1496
|
+
* });
|
|
1497
|
+
* ```
|
|
1498
|
+
*
|
|
1499
|
+
* @param path - key or array of keys
|
|
1500
|
+
* @param value - value to set
|
|
1501
|
+
*/
|
|
1502
|
+
<T extends PickQueryResult>(this: T, path: MaybeArray<string | number>, value: unknown): T;
|
|
1503
|
+
_opType: never;
|
|
1504
|
+
};
|
|
1505
|
+
jsonInsert: {
|
|
1506
|
+
/**
|
|
1507
|
+
* Inserts a value into a given position of JSON array and returns the whole array.
|
|
1508
|
+
* The path is a key or an array of keys to access the value.
|
|
1509
|
+
*
|
|
1510
|
+
* If a value exists at the given path, the value is not replaced.
|
|
1511
|
+
*
|
|
1512
|
+
* Provide `{ after: true }` option to insert a value after a given position.
|
|
1513
|
+
*
|
|
1514
|
+
* Calls the [jsonb_insert](https://www.postgresql.org/docs/current/functions-json.html) Postgres function.
|
|
1515
|
+
*
|
|
1516
|
+
* It can be used in all contexts on a single JSON value.
|
|
1517
|
+
*
|
|
1518
|
+
* ```ts
|
|
1519
|
+
* // update the record with data { tags: ['two'] } to have data { tags: ['one', 'two'] }
|
|
1520
|
+
* await db.table.find(id).update({
|
|
1521
|
+
* data: (q) => q.get('data').jsonInsert(['tags', 0], 'one'),
|
|
1522
|
+
* });
|
|
1523
|
+
*
|
|
1524
|
+
* // add 'three' after 'two'
|
|
1525
|
+
* await db.table.find(id).update({
|
|
1526
|
+
* data: (q) => q.get('data').jsonInsert(['tags', 1], 'three', { after: true }),
|
|
1527
|
+
* });
|
|
1528
|
+
* ```
|
|
1529
|
+
*
|
|
1530
|
+
* @param path - key or array of keys
|
|
1531
|
+
* @param value - value to insert
|
|
1532
|
+
* @param options - can have `after: true`
|
|
1533
|
+
*/
|
|
1534
|
+
<T extends PickQueryResult>(this: T, path: MaybeArray<string | number>, value: unknown, options?: {
|
|
1535
|
+
after?: boolean;
|
|
1536
|
+
}): T;
|
|
1537
|
+
_opType: never;
|
|
1538
|
+
};
|
|
1539
|
+
jsonRemove: {
|
|
1540
|
+
/**
|
|
1541
|
+
* Remove a value from a JSON object or array at a given path.
|
|
1542
|
+
* The path is a key or an array of keys to access the value.
|
|
1543
|
+
*
|
|
1544
|
+
* Uses the [#-](https://www.postgresql.org/docs/current/functions-json.html) Postgres operator.
|
|
1545
|
+
*
|
|
1546
|
+
* It can be used in all contexts on a single JSON value.
|
|
1547
|
+
*
|
|
1548
|
+
* ```ts
|
|
1549
|
+
* // the record has data { tags: ['one', 'two'] }
|
|
1550
|
+
* // removing the first tag, the data will be { tags: ['two'] }
|
|
1551
|
+
* const result = await db.table.find(id).update({
|
|
1552
|
+
* data: (q) => q.get('data').jsonRemove(['tags', 0]),
|
|
1553
|
+
* });
|
|
1554
|
+
* ```
|
|
1555
|
+
*
|
|
1556
|
+
* @param path - key or array of keys
|
|
1557
|
+
*/
|
|
1558
|
+
<T extends PickQueryResult>(this: T, path: MaybeArray<string | number>): T;
|
|
1559
|
+
_opType: never;
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
type OperatorsAny = Base<any>;
|
|
1563
|
+
type OperatorsDate = Ord<Date | string>;
|
|
1564
|
+
type OperatorsArray = Base<any>;
|
|
1565
|
+
type OperatorsTime = Ord<string>;
|
|
1566
|
+
declare const Operators: {
|
|
1567
|
+
any: OperatorsAny;
|
|
1568
|
+
boolean: OperatorsBoolean;
|
|
1569
|
+
number: OperatorsNumber;
|
|
1570
|
+
date: OperatorsDate;
|
|
1571
|
+
time: OperatorsTime;
|
|
1572
|
+
text: OperatorsText;
|
|
1573
|
+
json: OperatorsJson;
|
|
1574
|
+
array: OperatorsArray;
|
|
1575
|
+
};
|
|
1576
|
+
|
|
1480
1577
|
declare class ColumnRefExpression<T extends QueryColumn> extends Expression<T> {
|
|
1481
1578
|
name: string;
|
|
1482
1579
|
result: {
|
|
@@ -1622,9 +1719,9 @@ type WhereArg<T extends PickQueryMetaRelations> = {
|
|
|
1622
1719
|
* ```
|
|
1623
1720
|
*/
|
|
1624
1721
|
type WhereQueryBuilder<T extends PickQueryRelations> = RelationsBase extends T['relations'] ? {
|
|
1625
|
-
[K in keyof T]: K extends keyof QueryBase | keyof Where | keyof ExpressionMethods | 'sql' ? T[K] : never;
|
|
1722
|
+
[K in keyof T]: K extends keyof QueryBase | keyof Where | keyof ExpressionMethods | 'sql' | 'get' | 'ref' ? T[K] : never;
|
|
1626
1723
|
} : {
|
|
1627
|
-
[K in keyof T]: K extends keyof T['relations'] ? T['relations'][K] : K extends keyof QueryBase | keyof Where | keyof ExpressionMethods | 'sql' ? T[K] : never;
|
|
1724
|
+
[K in keyof T]: K extends keyof T['relations'] ? T['relations'][K] : K extends keyof QueryBase | keyof Where | keyof ExpressionMethods | 'sql' | 'get' | 'ref' ? T[K] : never;
|
|
1628
1725
|
};
|
|
1629
1726
|
type WhereArgs<T extends PickQueryMetaRelations> = WhereArg<T>[];
|
|
1630
1727
|
type WhereNotArgs<T extends PickQueryMetaRelations> = [WhereArg<T>];
|
|
@@ -2448,7 +2545,7 @@ declare class DynamicRawSQL<T extends QueryColumn, ColumnTypes = DefaultColumnTy
|
|
|
2448
2545
|
}
|
|
2449
2546
|
declare function raw<T = never>(...args: StaticSQLArgs): RawSQL<QueryColumn<T>>;
|
|
2450
2547
|
declare function raw<T = never>(...args: [DynamicSQLArg]): DynamicRawSQL<QueryColumn<T>>;
|
|
2451
|
-
declare const countSelect: RawSQL<QueryColumn<unknown,
|
|
2548
|
+
declare const countSelect: RawSQL<QueryColumn<unknown, any>, DefaultColumnTypes<ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>>>[];
|
|
2452
2549
|
declare function sqlQueryArgsToExpression(args: SQLQueryArgs): RawSQL<QueryColumn>;
|
|
2453
2550
|
type SqlFn = <T, Args extends [sql: TemplateStringsArray, ...values: unknown[]] | [sql: string] | [values: RecordUnknown, sql?: string]>(this: T, ...args: Args) => Args extends [RecordUnknown] ? (...sql: TemplateLiteralArgs) => RawSQLBase<QueryColumn, T> : RawSQLBase<QueryColumn, T>;
|
|
2454
2551
|
declare const sqlFn: SqlFn;
|
|
@@ -2940,7 +3037,7 @@ interface DefaultSchemaConfig extends ColumnSchemaConfig<ColumnType> {
|
|
|
2940
3037
|
dateAsDate(): ParseColumn<DateBaseColumn<DefaultSchemaConfig>, unknown, Date>;
|
|
2941
3038
|
enum<U extends string, T extends readonly [U, ...U[]]>(dataType: string, type: T): EnumColumn<DefaultSchemaConfig, unknown, U, T>;
|
|
2942
3039
|
array<Item extends ArrayColumnValue>(item: Item): ArrayColumn<DefaultSchemaConfig, Item, unknown, unknown, unknown>;
|
|
2943
|
-
json<T
|
|
3040
|
+
json<T extends MaybeArray<string | number | boolean | RecordUnknown>>(): JSONColumn<T, DefaultSchemaConfig>;
|
|
2944
3041
|
inputSchema(): undefined;
|
|
2945
3042
|
outputSchema(): undefined;
|
|
2946
3043
|
querySchema(): undefined;
|
|
@@ -3258,7 +3355,7 @@ interface DbResult<ColumnTypes> extends Db<string, never, never, never, never, n
|
|
|
3258
3355
|
* })
|
|
3259
3356
|
* ```
|
|
3260
3357
|
*/
|
|
3261
|
-
declare const createDb: <SchemaConfig extends ColumnSchemaConfig<ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any,
|
|
3358
|
+
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, nowSQL, schemaConfig, columnTypes: ctOrFn, ...options }: DbOptions<SchemaConfig, ColumnTypes>) => DbResult<ColumnTypes>;
|
|
3262
3359
|
declare const _initQueryBuilder: (adapter: Adapter, columnTypes: unknown, transactionStorage: AsyncLocalStorage<TransactionState>, commonOptions: DbTableOptions<undefined, QueryColumns>, options: DbSharedOptions) => Db;
|
|
3263
3360
|
|
|
3264
3361
|
type ToSQLCtx = {
|
|
@@ -3336,7 +3433,7 @@ declare function _queryGet<T extends QueryGetSelf, Arg extends GetArg<T>>(self:
|
|
|
3336
3433
|
declare function _queryGetOptional<T extends QueryGetSelf, Arg extends GetArg<T>>(self: T, arg: Arg): GetResultOptional<T, Arg>;
|
|
3337
3434
|
|
|
3338
3435
|
declare const isSelectingCount: (q: PickQueryQ) => boolean;
|
|
3339
|
-
type QueryReturnsAgg<T, C, Op
|
|
3436
|
+
type QueryReturnsAgg<T, C, Op> = SetQueryReturnsColumnOrThrow<T, QueryColumn<C, Op>> & Op;
|
|
3340
3437
|
type CountReturn<T> = QueryReturnsAgg<T, number, OperatorsNumber> & {
|
|
3341
3438
|
isCount: true;
|
|
3342
3439
|
};
|
|
@@ -3975,7 +4072,7 @@ declare class Create {
|
|
|
3975
4072
|
* const createdCount = await db.table.insertMany([data, data, data]);
|
|
3976
4073
|
* ```
|
|
3977
4074
|
*
|
|
3978
|
-
* Because of a limitation of Postgres protocol, queries having more than **
|
|
4075
|
+
* Because of a limitation of Postgres protocol, queries having more than **65535** of values are going to fail in runtime.
|
|
3979
4076
|
* To solve this seamlessly, OrchidORM will automatically batch such queries, and wrap them into a transaction, unless they are already in a transaction.
|
|
3980
4077
|
*
|
|
3981
4078
|
* ```ts
|
|
@@ -4778,153 +4875,6 @@ declare abstract class QueryHooks {
|
|
|
4778
4875
|
afterDeleteCommit<T extends PickQueryShape, S extends HookSelect<T>>(this: T, select: S, cb: AfterHook<S, T['shape']>): T;
|
|
4779
4876
|
}
|
|
4780
4877
|
|
|
4781
|
-
type JsonColumnName<T extends PickQueryMeta> = {
|
|
4782
|
-
[K in keyof T['meta']['selectable']]: T['meta']['selectable'][K]['column']['dataType'] extends 'jsonb' ? K : never;
|
|
4783
|
-
}[keyof T['meta']['selectable']] & string;
|
|
4784
|
-
type ColumnOrJsonMethod<T extends PickQueryMeta> = JsonColumnName<T> | JsonItem;
|
|
4785
|
-
type JsonSetResult<T extends PickQueryMetaShapeResultReturnType, Column extends ColumnOrJsonMethod<T>, As extends string> = JsonItem<As, Column extends keyof T['shape'] ? T['shape'][Column] : Column extends JsonItem ? Column['__json'][2] : QueryColumn> & AddQuerySelect<T, Record<As, Column extends keyof T['shape'] ? T['shape'][Column] : Column extends JsonItem ? Column['__json'][2] : QueryColumn>>;
|
|
4786
|
-
type JsonPathQueryResult<T extends PickQueryMetaResultReturnType, As extends string, Type extends QueryColumn> = JsonItem & AddQuerySelect<T, {
|
|
4787
|
-
[K in As]: Type;
|
|
4788
|
-
}>;
|
|
4789
|
-
declare abstract class JsonModifiers {
|
|
4790
|
-
/**
|
|
4791
|
-
* Return a JSON value/object/array where a given value is set at the given path.
|
|
4792
|
-
* The path is an array of keys to access the value.
|
|
4793
|
-
*
|
|
4794
|
-
* Can be used in `update` callback.
|
|
4795
|
-
*
|
|
4796
|
-
* ```ts
|
|
4797
|
-
* const result = await db.table.jsonSet('data', ['name'], 'new value').take();
|
|
4798
|
-
*
|
|
4799
|
-
* expect(result.data).toEqual({ name: 'new value' });
|
|
4800
|
-
* ```
|
|
4801
|
-
*
|
|
4802
|
-
* Optionally takes parameters of type `{ as?: string, createIfMissing?: boolean }`
|
|
4803
|
-
*
|
|
4804
|
-
* ```ts
|
|
4805
|
-
* await db.table.jsonSet('data', ['name'], 'new value', {
|
|
4806
|
-
* as: 'alias', // select data as `alias`
|
|
4807
|
-
* createIfMissing: true, // ignored if missing by default
|
|
4808
|
-
* });
|
|
4809
|
-
* ```
|
|
4810
|
-
*
|
|
4811
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
4812
|
-
* @param path - path to value inside the json
|
|
4813
|
-
* @param value - value to set into the json
|
|
4814
|
-
* @param options - `as` to alias the json value when selecting, `createIfMissing: true` will create a new JSON property if it didn't exist before
|
|
4815
|
-
*/
|
|
4816
|
-
jsonSet<T extends PickQueryMetaShapeResultReturnType, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
4817
|
-
as?: As;
|
|
4818
|
-
createIfMissing?: boolean;
|
|
4819
|
-
}): JsonSetResult<T, Column, As>;
|
|
4820
|
-
/**
|
|
4821
|
-
* Return a JSON value/object/array where a given value is inserted at the given JSON path. Value can be a single value or JSON object. If a value exists at the given path, the value is not replaced.
|
|
4822
|
-
*
|
|
4823
|
-
* Can be used in `update` callback.
|
|
4824
|
-
*
|
|
4825
|
-
* ```ts
|
|
4826
|
-
* // imagine user has data = { tags: ['two'] }
|
|
4827
|
-
* const result = await db.table.jsonInsert('data', ['tags', 0], 'one').take();
|
|
4828
|
-
*
|
|
4829
|
-
* // 'one' is inserted to 0 position
|
|
4830
|
-
* expect(result.data).toEqual({ tags: ['one', 'two'] });
|
|
4831
|
-
* ```
|
|
4832
|
-
*
|
|
4833
|
-
* Optionally takes parameters of type `{ as?: string, insertAfter?: boolean }`
|
|
4834
|
-
*
|
|
4835
|
-
* ```ts
|
|
4836
|
-
* // imagine user has data = { tags: ['one'] }
|
|
4837
|
-
* const result = await db.table
|
|
4838
|
-
* .jsonInsert('data', ['tags', 0], 'two', {
|
|
4839
|
-
* as: 'alias', // select as an alias
|
|
4840
|
-
* insertAfter: true, // insert after the specified position
|
|
4841
|
-
* })
|
|
4842
|
-
* .take();
|
|
4843
|
-
*
|
|
4844
|
-
* // 'one' is inserted to 0 position
|
|
4845
|
-
* expect(result.alias).toEqual({ tags: ['one', 'two'] });
|
|
4846
|
-
* ```
|
|
4847
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
4848
|
-
* @param path - path to the array inside the json, last path element is index to insert into
|
|
4849
|
-
* @param value - value to insert into the json array
|
|
4850
|
-
* @param options - `as` to alias the json value when selecting, `insertAfter: true` to insert after the specified position
|
|
4851
|
-
*/
|
|
4852
|
-
jsonInsert<T extends PickQueryMetaShapeResultReturnType, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, value: unknown, options?: {
|
|
4853
|
-
as?: As;
|
|
4854
|
-
insertAfter?: boolean;
|
|
4855
|
-
}): JsonSetResult<T, Column, As>;
|
|
4856
|
-
/**
|
|
4857
|
-
* Return a JSON value/object/array where a given value is removed at the given JSON path.
|
|
4858
|
-
*
|
|
4859
|
-
* Can be used in `update` callback.
|
|
4860
|
-
*
|
|
4861
|
-
* ```ts
|
|
4862
|
-
* // imagine a user has data = { tags: ['one', 'two'] }
|
|
4863
|
-
* const result = await db.table
|
|
4864
|
-
* .jsonRemove(
|
|
4865
|
-
* 'data',
|
|
4866
|
-
* ['tags', 0],
|
|
4867
|
-
* // optional parameters:
|
|
4868
|
-
* {
|
|
4869
|
-
* as: 'alias', // select as an alias
|
|
4870
|
-
* },
|
|
4871
|
-
* )
|
|
4872
|
-
* .take();
|
|
4873
|
-
*
|
|
4874
|
-
* expect(result.alias).toEqual({ tags: ['two'] });
|
|
4875
|
-
* ```
|
|
4876
|
-
*
|
|
4877
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
4878
|
-
* @param path - path to the array inside the json, last path element is index to remove this element
|
|
4879
|
-
* @param options - `as` to alias the json value when selecting
|
|
4880
|
-
*/
|
|
4881
|
-
jsonRemove<T extends PickQueryMetaShapeResultReturnType, Column extends ColumnOrJsonMethod<T>, As extends string = Column extends JsonItem ? Column['__json'][1] : Column>(this: T, column: Column, path: Array<string | number>, options?: {
|
|
4882
|
-
as?: As;
|
|
4883
|
-
}): JsonSetResult<T, Column, As>;
|
|
4884
|
-
/**
|
|
4885
|
-
* Selects a value from JSON data using a JSON path.
|
|
4886
|
-
*
|
|
4887
|
-
* ```ts
|
|
4888
|
-
* import { columnTypes } from 'orchid-orm';
|
|
4889
|
-
*
|
|
4890
|
-
* db.table.jsonPathQuery(
|
|
4891
|
-
* columnTypes.text(3, 100), // type of the value
|
|
4892
|
-
* 'data', // name of the JSON column
|
|
4893
|
-
* '$.name', // JSON path
|
|
4894
|
-
* 'name', // select value as name
|
|
4895
|
-
*
|
|
4896
|
-
* // Optionally supports `vars` and `silent` options
|
|
4897
|
-
* // check Postgres docs for jsonb_path_query for details
|
|
4898
|
-
* {
|
|
4899
|
-
* vars: 'vars',
|
|
4900
|
-
* silent: true,
|
|
4901
|
-
* },
|
|
4902
|
-
* );
|
|
4903
|
-
* ```
|
|
4904
|
-
*
|
|
4905
|
-
* Nested JSON operations can be used in place of JSON column name:
|
|
4906
|
-
*
|
|
4907
|
-
* ```ts
|
|
4908
|
-
* db.table.jsonPathQuery(
|
|
4909
|
-
* columnTypes.text(3, 100),
|
|
4910
|
-
* // Available: .jsonSet, .jsonInsert, .jsonRemove
|
|
4911
|
-
* db.table.jsonSet('data', ['key'], 'value'),
|
|
4912
|
-
* '$.name',
|
|
4913
|
-
* 'name',
|
|
4914
|
-
* );
|
|
4915
|
-
* ```
|
|
4916
|
-
*
|
|
4917
|
-
* @param type - provide a column type to have a correct result type
|
|
4918
|
-
* @param column - name of JSON column, or a result of a nested json method
|
|
4919
|
-
* @param path - special JSON path string to reference a JSON value
|
|
4920
|
-
* @param as - optional alias for the selected value
|
|
4921
|
-
* @param options - supports `vars` and `silent`, check Postgres docs of `json_path_query` for these
|
|
4922
|
-
*/
|
|
4923
|
-
jsonPathQuery<T extends PickQueryMetaShapeResultReturnType, As extends string, Type extends QueryColumn>(this: T, type: Type, column: ColumnOrJsonMethod<T>, path: string, as: As, options?: {
|
|
4924
|
-
vars?: string;
|
|
4925
|
-
silent?: boolean;
|
|
4926
|
-
}): JsonPathQueryResult<T, As, Type>;
|
|
4927
|
-
}
|
|
4928
4878
|
declare abstract class JsonMethods {
|
|
4929
4879
|
/**
|
|
4930
4880
|
* Wraps the query in a way to select a single JSON string.
|
|
@@ -5484,15 +5434,14 @@ declare class Union {
|
|
|
5484
5434
|
exceptAll<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
|
|
5485
5435
|
}
|
|
5486
5436
|
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
}
|
|
5437
|
+
interface UpdateSelf extends PickQueryMetaResultRelationsWithDataReturnTypeShape {
|
|
5438
|
+
inputType: RecordUnknown;
|
|
5439
|
+
}
|
|
5490
5440
|
type UpdateData<T extends UpdateSelf> = {
|
|
5491
5441
|
[K in keyof T['inputType']]?: UpdateColumn<T, K>;
|
|
5492
5442
|
} & {
|
|
5493
5443
|
[K in keyof T['relations']]?: UpdateRelationData<T, T['relations'][K]['relationConfig']>;
|
|
5494
5444
|
};
|
|
5495
|
-
type UpdateColumnArgKeys = keyof JsonModifiers | keyof ExpressionMethods | 'sql' | 'meta' | 'shape' | 'result' | 'returnType' | 'columnTypes';
|
|
5496
5445
|
interface UpdateQueryOrExpression<T> extends QueryOrExpression<T> {
|
|
5497
5446
|
meta: {
|
|
5498
5447
|
kind: 'select';
|
|
@@ -5500,9 +5449,7 @@ interface UpdateQueryOrExpression<T> extends QueryOrExpression<T> {
|
|
|
5500
5449
|
}
|
|
5501
5450
|
type UpdateColumn<T extends UpdateSelf, Key extends keyof T['inputType']> = T['inputType'][Key] | QueryOrExpression<T['inputType'][Key]> | {
|
|
5502
5451
|
[K in keyof Query]: K extends 'then' ? QueryThen<T['inputType'][Key]> : Query[K];
|
|
5503
|
-
} | ((q:
|
|
5504
|
-
[K in keyof T['relations'] | UpdateColumnArgKeys]: K extends keyof T['relations'] ? T['relations'][K] : K extends UpdateColumnArgKeys ? T[K] : never;
|
|
5505
|
-
}) => JsonItem | UpdateQueryOrExpression<T['inputType'][Key]>);
|
|
5452
|
+
} | ((q: T) => UpdateQueryOrExpression<T['inputType'][Key]> | QueryOrExpression<T['inputType'][Key]>);
|
|
5506
5453
|
type UpdateRelationData<T extends UpdateSelf, Rel extends RelationConfigBase> = QueryReturnsAll<T['returnType']> extends true ? Rel['dataForUpdate'] : Rel['one'] extends true ? Rel['dataForUpdate'] | Rel['dataForUpdateOne'] : Rel['dataForUpdate'] & Rel['dataForUpdateOne'];
|
|
5507
5454
|
type UpdateArg<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? UpdateData<T> : never;
|
|
5508
5455
|
type UpdateRawArgs<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? SQLQueryArgs : never;
|
|
@@ -5918,7 +5865,7 @@ declare module './aggregate' {
|
|
|
5918
5865
|
* @param search - name of the search to use the query from
|
|
5919
5866
|
* @param options - `text` for a text source, `options` for `ts_headline` options
|
|
5920
5867
|
*/
|
|
5921
|
-
headline<T extends PickQueryMeta>(this: T, search: HeadlineSearchArg<T>, options?: HeadlineParams<T>):
|
|
5868
|
+
headline<T extends PickQueryMeta>(this: T, search: HeadlineSearchArg<T>, options?: HeadlineParams<T>): SetQueryReturnsColumnOrThrow<T, QueryColumn<string>>;
|
|
5922
5869
|
}
|
|
5923
5870
|
}
|
|
5924
5871
|
type SearchArg<T extends PickQueryMeta, As extends string> = {
|
|
@@ -6403,7 +6350,7 @@ declare const _queryExec: <T extends Query>(q: T) => never;
|
|
|
6403
6350
|
declare const _queryFindBy: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOne<WhereResult<T>>;
|
|
6404
6351
|
declare const _queryFindByOptional: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOneOptional<WhereResult<T>>;
|
|
6405
6352
|
declare const _queryRows: <T extends Query>(q: T) => SetQueryReturnsRows<T>;
|
|
6406
|
-
interface QueryMethods<ColumnTypes> extends AsMethods, AggregateMethods, Select, FromMethods, Join, WithMethods, Union,
|
|
6353
|
+
interface QueryMethods<ColumnTypes> extends AsMethods, AggregateMethods, Select, FromMethods, Join, WithMethods, Union, JsonMethods, Create, Update, Delete, Transaction, For, Where, SearchMethods, Clear, Having, QueryLog, QueryHooks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, SqlMethod<ColumnTypes>, TransformMethods, ScopeMethods, SoftDeleteMethods, ExpressionMethods {
|
|
6407
6354
|
}
|
|
6408
6355
|
declare class QueryMethods<ColumnTypes> {
|
|
6409
6356
|
/**
|
|
@@ -7056,6 +7003,8 @@ interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaRe
|
|
|
7056
7003
|
}
|
|
7057
7004
|
interface PickQueryWithDataColumnTypes extends PickQueryWithData, PickQueryColumnTypes {
|
|
7058
7005
|
}
|
|
7006
|
+
interface PickQueryResultColumnTypes extends PickQueryResult, PickQueryColumnTypes {
|
|
7007
|
+
}
|
|
7059
7008
|
interface PickQueryMetaWithDataColumnTypes extends PickQueryMeta, PickQueryWithData, PickQueryColumnTypes {
|
|
7060
7009
|
}
|
|
7061
7010
|
interface PickQueryMetaTable extends PickQueryMeta, PickQueryTable {
|
|
@@ -7175,7 +7124,7 @@ type SetQueryReturnsPluckColumnKindResult<T extends PickQueryMetaResult, Kind ex
|
|
|
7175
7124
|
pluck: T['result']['value'];
|
|
7176
7125
|
} : K extends 'returnType' ? 'pluck' : K extends 'result' ? Result : K extends 'then' ? QueryThen<T['result']['value']['outputType'][]> : T[K];
|
|
7177
7126
|
} & QueryMetaHasSelect;
|
|
7178
|
-
type SetQueryReturnsValueOrThrow<T extends PickQueryMeta, Arg extends
|
|
7127
|
+
type SetQueryReturnsValueOrThrow<T extends PickQueryMeta, Arg extends keyof T['meta']['selectable']> = SetQueryReturnsColumnOrThrow<T, T['meta']['selectable'][Arg]['column']> & T['meta']['selectable'][Arg]['column']['operators'];
|
|
7179
7128
|
type SetQueryReturnsValueOptional<T extends PickQueryMeta, Arg extends GetStringArg<T>> = SetQueryReturnsColumnOptional<T, {
|
|
7180
7129
|
[K in keyof T['meta']['selectable'][Arg]['column']]: K extends 'outputType' ? T['meta']['selectable'][Arg]['column'][K] | undefined : T['meta']['selectable'][Arg]['column'][K];
|
|
7181
7130
|
}> & Omit<T['meta']['selectable'][Arg]['column']['operators'], 'equals' | 'not'> & OperatorsNullable<T['meta']['selectable'][Arg]['column']>;
|
|
@@ -7270,7 +7219,7 @@ interface ColumnFromDbParams {
|
|
|
7270
7219
|
interface PickColumnData {
|
|
7271
7220
|
data: ColumnData;
|
|
7272
7221
|
}
|
|
7273
|
-
declare abstract class ColumnType<Schema extends ColumnTypeSchemaArg = ColumnTypeSchemaArg, Type = unknown, InputSchema = any, Ops
|
|
7222
|
+
declare abstract class ColumnType<Schema extends ColumnTypeSchemaArg = ColumnTypeSchemaArg, Type = unknown, InputSchema = any, Ops = any, InputType = Type, OutputType = Type, OutputSchema = InputSchema, QueryType = InputType, QuerySchema = InputSchema> extends ColumnTypeBase<Schema, Type, InputSchema, Ops, InputType, OutputType, OutputSchema, QueryType, QuerySchema, ColumnData> {
|
|
7274
7223
|
/**
|
|
7275
7224
|
* Mark the column as a primary key.
|
|
7276
7225
|
* This column type becomes an argument of the `.find` method.
|
|
@@ -7631,9 +7580,9 @@ interface DefaultColumnTypes<SchemaConfig extends ColumnSchemaConfig> extends Ti
|
|
|
7631
7580
|
type(dataType: string): CustomTypeColumn<SchemaConfig>;
|
|
7632
7581
|
domain(dataType: string): DomainColumn<SchemaConfig>;
|
|
7633
7582
|
}
|
|
7634
|
-
declare const makeColumnTypes: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any,
|
|
7583
|
+
declare const makeColumnTypes: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>>(schema: SchemaConfig) => DefaultColumnTypes<SchemaConfig>;
|
|
7635
7584
|
|
|
7636
|
-
declare const simplifyColumnDefault: (value?: string) => RawSQL<orchid_core.QueryColumn<unknown,
|
|
7585
|
+
declare const simplifyColumnDefault: (value?: string) => RawSQL<orchid_core.QueryColumn<unknown, any>, DefaultColumnTypes<orchid_core.ColumnSchemaConfig<ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>>> | undefined;
|
|
7637
7586
|
declare const instantiateColumn: (typeFn: () => ColumnTypeBase, params: ColumnFromDbParams) => ColumnTypeBase;
|
|
7638
7587
|
|
|
7639
7588
|
interface ColumnsShape {
|
|
@@ -7904,4 +7853,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
|
|
|
7904
7853
|
*/
|
|
7905
7854
|
declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
|
|
7906
7855
|
|
|
7907
|
-
export { Adapter, AdapterConfig, AdapterOptions, AddQueryDefaults, AddQuerySelect, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayColumnValue, ArrayData, AsMethods, AsQueryArg,
|
|
7856
|
+
export { Adapter, AdapterConfig, AdapterOptions, AddQueryDefaults, AddQuerySelect, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayColumnValue, ArrayData, AsMethods, AsQueryArg, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanQueryColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ClearStatement, CloneSelfKeys, ColumnData, ColumnFromDbParams, ColumnInfoQueryData, ColumnOperators, ColumnRefExpression, ColumnType, ColumnsByType, ColumnsShape, ColumnsShapeToNullableObject, ColumnsShapeToObject, ColumnsShapeToObjectArray, ColumnsShapeToPluck, CommonQueryData, ComputedColumnsBase, CopyOptions, CopyQueryData, Create, CreateBelongsToData, CreateColumn, CreateCtx, CreateData, CreateKind, CreateMethodsNames, CreateRelationsData, CreateRelationsDataOmittingFKeys, CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, DbDomainArg, DbDomainArgRecord, DbExtension, DbOptions, DbResult, DbSharedOptions, DbTableConstructor, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultSchemaConfig, Delete, DeleteArgs, DeleteMethodsNames, DeleteQueryData, DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, ExpressionOutput, FnExpression, FnExpressionArgs, FnExpressionArgsPairs, FnExpressionArgsValue, For, FromArg, FromMethods, FromQuerySelf, FromResult, GetArg, GetColumnInfo, GetQueryResult, GetResult, GetResultOptional, GetStringArg, GroupArg, Having, HavingItem, HookAction, HookSelect, IdentityColumn, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsolationLevel, JSONColumn, JSONTextColumn, Join, JoinArgs, JoinCallback, JoinFirstArg, JoinItem, JoinItemArgs, JoinLateralCallback, JoinLateralItem, JoinLateralResult, JoinOverrides, JoinQueryBuilder, JoinQueryMethod, JoinResult, JoinedParsers, JoinedShapes, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NoPrimaryKeyOption, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumnData, OnConflictMerge, OnConflictQueryBuilder, OnConflictSet, OnConflictTarget, OnMethods, Operator, Operators, OperatorsAny, OperatorsArray, OperatorsBoolean, OperatorsDate, OperatorsJson, OperatorsNumber, OperatorsText, OperatorsTime, OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgSelf, OrderArgs, OrderItem, OrderTsQueryConfig, Over, PathColumn, PickColumnData, PickQueryBaseQuery, PickQueryColumnTypes, PickQueryDataShapeAndJoinedShapes, PickQueryInternal, PickQueryMetaRelations, PickQueryMetaResultRelations, PickQueryMetaResultRelationsWindows, PickQueryMetaResultRelationsWindowsColumnTypes, PickQueryMetaResultRelationsWithDataReturnType, PickQueryMetaResultRelationsWithDataReturnTypeShape, PickQueryMetaResultReturnTypeWithDataWindows, PickQueryMetaResultReturnTypeWithDataWindowsTable, PickQueryMetaShapeRelationsWithData, PickQueryMetaTable, PickQueryMetaTableShape, PickQueryMetaTableShapeReturnTypeWithData, PickQueryMetaWithData, PickQueryMetaWithDataColumnTypes, PickQueryQ, PickQueryQAndBaseQuery, PickQueryQAndInternal, PickQueryRelations, PickQueryRelationsWithData, PickQueryResultColumnTypes, PickQueryShapeResultSinglePrimaryKey, PickQueryShapeSinglePrimaryKey, PickQuerySinglePrimaryKey, PickQueryWindows, PickQueryWithData, PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, Query, QueryAfterHook, QueryArraysResult, QueryBase, QueryBaseThen, QueryBeforeHook, QueryData, QueryDataFromItem, QueryDataJoinTo, QueryDefaultReturnData, QueryError, QueryErrorName, QueryGet, QueryGetSelf, QueryHelperResult, QueryHookSelect, QueryHooks, QueryInternal, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMetaHasSelect, QueryMetaHasWhere, QueryMethods, QueryOrExpression, QueryOrExpressionBooleanOrNullResult, QueryResult, QueryReturnsAll, QueryScopeData, QueryScopes, QuerySourceItem, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithComputed, QueryWithTable, RawSQL, RealColumn, RecordOfColumnsShapeBase, RefExpression, RelationConfigBase, RelationConfigDataForCreate, RelationJoinQuery, RelationQuery, RelationQueryBase, RelationsBase, SearchArg, SearchMethods, SearchWeight, SearchWeightRecord, Select, SelectArg, SelectAs, SelectItem, SelectQueryData, SelectSubQueryResult, SelectableFromShape, SelectableOfType, SelectableOrExpression, SelectableOrExpressionOfType, SerialColumn, SerialColumnData, SetQueryKind, SetQueryKindResult, SetQueryReturnsAll, SetQueryReturnsAllKind, SetQueryReturnsAllKindResult, SetQueryReturnsColumnInfo, SetQueryReturnsColumnKind, SetQueryReturnsColumnKindResult, SetQueryReturnsColumnOptional, SetQueryReturnsColumnOrThrow, SetQueryReturnsOne, SetQueryReturnsOneKind, SetQueryReturnsOneKindResult, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsPluckColumn, SetQueryReturnsPluckColumnKind, SetQueryReturnsPluckColumnKindResult, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValueOptional, SetQueryReturnsValueOrThrow, SetQueryReturnsVoid, SetQueryReturnsVoidKind, SetQueryTableAlias, ShapeColumnPrimaryKeys, ShapeUniqueColumns, SimpleJoinItem, SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, SortDir, SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TextBaseColumn, TextColumn, TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, ToSQLCtx, ToSQLOptions, ToSQLQuery, Transaction, TransactionAdapter, TransactionOptions, TransformMethods, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionKind, UnionSet, UniqueConstraints, UniqueQueryTypeOrExpression, UniqueTableDataItem, UnknownColumn, Update, UpdateArg, UpdateCtx, UpdateCtxCollect, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdateSelf, UpdatedAtDataInjector, UpsertArg, UpsertResult, UpsertThis, VarCharColumn, VirtualColumn, Where, WhereArg, WhereArgs, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereNotArgs, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WhereSearchItem, WhereSearchResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowItem, WithArgsOptions, WithDataBase, WithDataItem, WithDataItems, WithItem, WithMethods, WithOptions, WithQueryBuilder, WithRecursiveOptions, WithResult, WithSqlResult, WrapQueryArg, XMLColumn, _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, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|