drizzle-orm 0.25.2 → 0.25.3-4cc2d87
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/aws-data-api/pg/index.cjs +234 -1
- package/aws-data-api/pg/index.cjs.map +1 -1
- package/aws-data-api/pg/index.d.ts +5 -6
- package/aws-data-api/pg/index.mjs +228 -1
- package/aws-data-api/pg/index.mjs.map +1 -1
- package/aws-data-api/pg/migrator.cjs +13 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.ts +5 -6
- package/aws-data-api/pg/migrator.mjs +11 -1
- package/aws-data-api/pg/migrator.mjs.map +1 -1
- package/better-sqlite3/index.cjs +119 -1
- package/better-sqlite3/index.cjs.map +1 -1
- package/better-sqlite3/index.d.ts +14 -12
- package/better-sqlite3/index.mjs +114 -1
- package/better-sqlite3/index.mjs.map +1 -1
- package/better-sqlite3/migrator.cjs +13 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.ts +5 -5
- package/better-sqlite3/migrator.mjs +11 -1
- package/better-sqlite3/migrator.mjs.map +1 -1
- package/bun-sqlite/index.cjs +126 -1
- package/bun-sqlite/index.cjs.map +1 -1
- package/bun-sqlite/index.d.ts +14 -12
- package/bun-sqlite/index.mjs +121 -1
- package/bun-sqlite/index.mjs.map +1 -1
- package/bun-sqlite/migrator.cjs +13 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.ts +5 -5
- package/bun-sqlite/migrator.mjs +11 -1
- package/bun-sqlite/migrator.mjs.map +1 -1
- package/{column.d-8b137277.d.ts → column.d-c31e7ad3.d.ts} +77 -6
- package/d1/index.cjs +116 -1
- package/d1/index.cjs.map +1 -1
- package/d1/index.d.ts +15 -12
- package/d1/index.mjs +111 -1
- package/d1/index.mjs.map +1 -1
- package/d1/migrator.cjs +13 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.ts +5 -5
- package/d1/migrator.mjs +11 -1
- package/d1/migrator.mjs.map +1 -1
- package/{db.d-ae495c35.d.ts → db.d-a2311092.d.ts} +121 -44
- package/{db.d-66553b9e.d.ts → db.d-bc9a1d6c.d.ts} +193 -16
- package/driver.d-17ca4c15.d.ts +8 -0
- package/driver.d-300ddb0e.d.ts +64 -0
- package/driver.d-45e56643.d.ts +60 -0
- package/driver.d-64f2125c.d.ts +8 -0
- package/driver.d-7fde2e9d.d.ts +55 -0
- package/driver.d-9d703b84.d.ts +8 -0
- package/driver.d-b2b94bf9.d.ts +46 -0
- package/driver.d-b70ee7ee.d.ts +55 -0
- package/driver.d-dea23ee6.d.ts +8 -0
- package/driver.d-e54af17b.d.ts +52 -0
- package/driver.d-eb490c91.d.ts +9 -0
- package/driver.d-ef6fa2df.d.ts +14 -0
- package/errors-bb636d84.mjs +19 -0
- package/errors-bb636d84.mjs.map +1 -0
- package/errors-d0192d62.cjs +22 -0
- package/errors-d0192d62.cjs.map +1 -0
- package/index.cjs +105 -1
- package/index.cjs.map +1 -1
- package/index.d.ts +16 -432
- package/index.mjs +3 -1
- package/index.mjs.map +1 -1
- package/knex/index.cjs +2 -1
- package/knex/index.cjs.map +1 -1
- package/knex/index.d.ts +1 -1
- package/kysely/index.cjs +2 -1
- package/kysely/index.cjs.map +1 -1
- package/kysely/index.d.ts +1 -1
- package/libsql/index.cjs +155 -1
- package/libsql/index.cjs.map +1 -1
- package/libsql/index.d.ts +14 -12
- package/libsql/index.mjs +150 -1
- package/libsql/index.mjs.map +1 -1
- package/libsql/migrator.cjs +13 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.ts +5 -5
- package/libsql/migrator.mjs +11 -1
- package/libsql/migrator.mjs.map +1 -1
- package/logger-caa1ca6e.cjs +34 -0
- package/logger-caa1ca6e.cjs.map +1 -0
- package/logger-caf75bde.mjs +30 -0
- package/logger-caf75bde.mjs.map +1 -0
- package/migrator.cjs +48 -1
- package/migrator.cjs.map +1 -1
- package/migrator.mjs +46 -1
- package/migrator.mjs.map +1 -1
- package/mysql-core/index.cjs +1004 -1
- package/mysql-core/index.cjs.map +1 -1
- package/mysql-core/index.d.ts +347 -347
- package/mysql-core/index.mjs +869 -1
- package/mysql-core/index.mjs.map +1 -1
- package/mysql2/index.cjs +230 -1
- package/mysql2/index.cjs.map +1 -1
- package/mysql2/index.d.ts +5 -6
- package/mysql2/index.mjs +223 -1
- package/mysql2/index.mjs.map +1 -1
- package/mysql2/migrator.cjs +13 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.ts +5 -6
- package/mysql2/migrator.mjs +11 -1
- package/mysql2/migrator.mjs.map +1 -1
- package/neon-serverless/index.cjs +155 -1
- package/neon-serverless/index.cjs.map +1 -1
- package/neon-serverless/index.d.ts +5 -6
- package/neon-serverless/index.mjs +149 -1
- package/neon-serverless/index.mjs.map +1 -1
- package/neon-serverless/migrator.cjs +13 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.ts +5 -6
- package/neon-serverless/migrator.mjs +11 -1
- package/neon-serverless/migrator.mjs.map +1 -1
- package/node-postgres/index.cjs +157 -1
- package/node-postgres/index.cjs.map +1 -1
- package/node-postgres/index.d.ts +5 -6
- package/node-postgres/index.mjs +151 -1
- package/node-postgres/index.mjs.map +1 -1
- package/node-postgres/migrator.cjs +13 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.ts +5 -6
- package/node-postgres/migrator.mjs +11 -1
- package/node-postgres/migrator.mjs.map +1 -1
- package/package.json +97 -34
- package/pg-core/index.cjs +652 -1
- package/pg-core/index.cjs.map +1 -1
- package/pg-core/index.d.ts +13 -7
- package/pg-core/index.mjs +501 -1
- package/pg-core/index.mjs.map +1 -1
- package/planetscale-serverless/index.cjs +111 -1
- package/planetscale-serverless/index.cjs.map +1 -1
- package/planetscale-serverless/index.d.ts +5 -6
- package/planetscale-serverless/index.mjs +106 -1
- package/planetscale-serverless/index.mjs.map +1 -1
- package/planetscale-serverless/migrator.cjs +13 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.ts +5 -6
- package/planetscale-serverless/migrator.mjs +11 -1
- package/planetscale-serverless/migrator.mjs.map +1 -1
- package/postgres-js/index.cjs +113 -1
- package/postgres-js/index.cjs.map +1 -1
- package/postgres-js/index.d.ts +5 -6
- package/postgres-js/index.mjs +108 -1
- package/postgres-js/index.mjs.map +1 -1
- package/postgres-js/migrator.cjs +13 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.ts +5 -6
- package/postgres-js/migrator.mjs +11 -1
- package/postgres-js/migrator.mjs.map +1 -1
- package/query-promise.d-e370e0a9.d.ts +617 -0
- package/relations-47eb5c5f.mjs +2954 -0
- package/relations-47eb5c5f.mjs.map +1 -0
- package/relations-5e2d30dd.cjs +3117 -0
- package/relations-5e2d30dd.cjs.map +1 -0
- package/{select.types.d-c3e86d45.d.ts → select.types.d-34d7f74e.d.ts} +1 -1
- package/{select.types.d-adb82002.d.ts → select.types.d-ae2f8e44.d.ts} +58 -14
- package/session-483ed08d.mjs +1263 -0
- package/session-483ed08d.mjs.map +1 -0
- package/session-6bd76405.cjs +362 -0
- package/session-6bd76405.cjs.map +1 -0
- package/session-a90df8a2.cjs +1252 -0
- package/session-a90df8a2.cjs.map +1 -0
- package/session-b99382a2.mjs +1223 -0
- package/session-b99382a2.mjs.map +1 -0
- package/session-c62f6348.cjs +1298 -0
- package/session-c62f6348.cjs.map +1 -0
- package/session-e8745392.mjs +351 -0
- package/session-e8745392.mjs.map +1 -0
- package/sql-js/index.cjs +175 -1
- package/sql-js/index.cjs.map +1 -1
- package/sql-js/index.d.ts +14 -12
- package/sql-js/index.mjs +170 -1
- package/sql-js/index.mjs.map +1 -1
- package/sql-js/migrator.cjs +13 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.ts +5 -5
- package/sql-js/migrator.mjs +11 -1
- package/sql-js/migrator.mjs.map +1 -1
- package/sqlite-core/index.cjs +516 -1
- package/sqlite-core/index.cjs.map +1 -1
- package/sqlite-core/index.d.ts +6 -5
- package/sqlite-core/index.mjs +441 -1
- package/sqlite-core/index.mjs.map +1 -1
- package/sqlite-proxy/index.cjs +118 -1
- package/sqlite-proxy/index.cjs.map +1 -1
- package/sqlite-proxy/index.d.ts +12 -11
- package/sqlite-proxy/index.mjs +113 -1
- package/sqlite-proxy/index.mjs.map +1 -1
- package/sqlite-proxy/migrator.cjs +25 -2
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.ts +5 -5
- package/sqlite-proxy/migrator.mjs +23 -2
- package/sqlite-proxy/migrator.mjs.map +1 -1
- package/version.cjs +9 -1
- package/version.cjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.mjs +6 -1
- package/version.mjs.map +1 -1
- package/README.md +0 -150
- package/column-builder-592f0191.mjs +0 -2
- package/column-builder-592f0191.mjs.map +0 -1
- package/column-builder-b48639f3.cjs +0 -2
- package/column-builder-b48639f3.cjs.map +0 -1
- package/driver.d-0158cd93.d.ts +0 -11
- package/driver.d-1f73a4a9.d.ts +0 -70
- package/driver.d-2e907d12.d.ts +0 -17
- package/driver.d-3781598a.d.ts +0 -11
- package/driver.d-3a8adf2a.d.ts +0 -61
- package/driver.d-59580d08.d.ts +0 -11
- package/driver.d-5f3fc125.d.ts +0 -12
- package/driver.d-693f7f9f.d.ts +0 -56
- package/driver.d-6c43e393.d.ts +0 -60
- package/driver.d-b00fc6ec.d.ts +0 -57
- package/driver.d-e4bd120b.d.ts +0 -47
- package/driver.d-f4b5b390.d.ts +0 -11
- package/index-59b7992d.cjs +0 -2
- package/index-59b7992d.cjs.map +0 -1
- package/index-b71998f1.mjs +0 -2
- package/index-b71998f1.mjs.map +0 -1
- package/logger-04bad527.cjs +0 -2
- package/logger-04bad527.cjs.map +0 -1
- package/logger-2598bf05.mjs +0 -2
- package/logger-2598bf05.mjs.map +0 -1
- package/logger.d-37185354.d.ts +0 -21
- package/query-builder-2f2e8229.cjs +0 -2
- package/query-builder-2f2e8229.cjs.map +0 -1
- package/query-builder-2fcde2f0.mjs +0 -2
- package/query-builder-2fcde2f0.mjs.map +0 -1
- package/query-promise-2c5b43ab.cjs +0 -2
- package/query-promise-2c5b43ab.cjs.map +0 -1
- package/query-promise-a65edd44.mjs +0 -2
- package/query-promise-a65edd44.mjs.map +0 -1
- package/query-promise.d-a8af8583.d.ts +0 -9
- package/session-8a621f09.mjs +0 -8
- package/session-8a621f09.mjs.map +0 -1
- package/session-b6939bab.cjs +0 -14
- package/session-b6939bab.cjs.map +0 -1
- package/session-b977ce56.mjs +0 -14
- package/session-b977ce56.mjs.map +0 -1
- package/session-c891400d.mjs +0 -8
- package/session-c891400d.mjs.map +0 -1
- package/session-e6db6732.cjs +0 -8
- package/session-e6db6732.cjs.map +0 -1
- package/session-ef1ef979.cjs +0 -8
- package/session-ef1ef979.cjs.map +0 -1
- package/utils-9d882195.cjs +0 -2
- package/utils-9d882195.cjs.map +0 -1
- package/utils-e6870670.mjs +0 -2
- package/utils-e6870670.mjs.map +0 -1
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
import { A as AnyColumn, S as SQL, a7 as SQLChunk, a9 as Placeholder, J as SQLWrapper, G as GetColumnData, T as Table, aj as AnyTable, a8 as sql, aw as SimplifyShallow, aA as ValueOrArray, ax as Assume, ay as Equal, ap as InferModelFromColumns, aG as ColumnsWithTable, ag as TableConfig } from './column.d-c31e7ad3.js';
|
|
2
|
+
|
|
3
|
+
declare function bindIfParam(value: unknown, column: AnyColumn | SQL.Aliased): SQLChunk;
|
|
4
|
+
/**
|
|
5
|
+
* Test that two values are equal.
|
|
6
|
+
*
|
|
7
|
+
* Remember that the SQL standard dictates that
|
|
8
|
+
* two NULL values are not equal, so if you want to test
|
|
9
|
+
* whether a value is null, you may want to use
|
|
10
|
+
* `isNull` instead.
|
|
11
|
+
*
|
|
12
|
+
* ## Examples
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Select cars made by Ford
|
|
16
|
+
* db.select().from(cars)
|
|
17
|
+
* .where(eq(cars.make, 'Ford'))
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see isNull for a way to test equality to NULL.
|
|
21
|
+
*/
|
|
22
|
+
declare function eq<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
23
|
+
declare function eq<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
24
|
+
/**
|
|
25
|
+
* Test that two values are not equal.
|
|
26
|
+
*
|
|
27
|
+
* Remember that the SQL standard dictates that
|
|
28
|
+
* two NULL values are not equal, so if you want to test
|
|
29
|
+
* whether a value is not null, you may want to use
|
|
30
|
+
* `isNotNull` instead.
|
|
31
|
+
*
|
|
32
|
+
* ## Examples
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Select cars not made by Ford
|
|
36
|
+
* db.select().from(cars)
|
|
37
|
+
* .where(ne(cars.make, 'Ford'))
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @see isNotNull for a way to test whether a value is not null.
|
|
41
|
+
*/
|
|
42
|
+
declare function ne<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
43
|
+
declare function ne<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
44
|
+
/**
|
|
45
|
+
* Combine a list of conditions with the `and` operator. Conditions
|
|
46
|
+
* that are equal `undefined` are automatically ignored.
|
|
47
|
+
*
|
|
48
|
+
* ## Examples
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* db.select().from(cars)
|
|
52
|
+
* .where(
|
|
53
|
+
* and(
|
|
54
|
+
* eq(cars.make, 'Volvo'),
|
|
55
|
+
* eq(cars.year, 1950),
|
|
56
|
+
* )
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function and(...conditions: (SQL | undefined)[]): SQL | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Combine a list of conditions with the `or` operator. Conditions
|
|
63
|
+
* that are equal `undefined` are automatically ignored.
|
|
64
|
+
*
|
|
65
|
+
* ## Examples
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* db.select().from(cars)
|
|
69
|
+
* .where(
|
|
70
|
+
* or(
|
|
71
|
+
* eq(cars.make, 'GM'),
|
|
72
|
+
* eq(cars.make, 'Ford'),
|
|
73
|
+
* )
|
|
74
|
+
* )
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function or(...conditions: (SQL | undefined)[]): SQL | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Negate the meaning of an expression using the `not` keyword.
|
|
80
|
+
*
|
|
81
|
+
* ## Examples
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* // Select cars _not_ made by GM or Ford.
|
|
85
|
+
* db.select().from(cars)
|
|
86
|
+
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function not(condition: SQL): SQL;
|
|
90
|
+
/**
|
|
91
|
+
* Test that the first expression passed is greater than
|
|
92
|
+
* the second expression.
|
|
93
|
+
*
|
|
94
|
+
* ## Examples
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* // Select cars made after 2000.
|
|
98
|
+
* db.select().from(cars)
|
|
99
|
+
* .where(gt(cars.year, 2000))
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @see gte for greater-than-or-equal
|
|
103
|
+
*/
|
|
104
|
+
declare function gt<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
105
|
+
declare function gt<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
106
|
+
/**
|
|
107
|
+
* Test that the first expression passed is greater than
|
|
108
|
+
* or equal to the second expression. Use `gt` to
|
|
109
|
+
* test whether an expression is strictly greater
|
|
110
|
+
* than another.
|
|
111
|
+
*
|
|
112
|
+
* ## Examples
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* // Select cars made on or after 2000.
|
|
116
|
+
* db.select().from(cars)
|
|
117
|
+
* .where(gte(cars.year, 2000))
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @see gt for a strictly greater-than condition
|
|
121
|
+
*/
|
|
122
|
+
declare function gte<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
123
|
+
declare function gte<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
124
|
+
/**
|
|
125
|
+
* Test that the first expression passed is less than
|
|
126
|
+
* the second expression.
|
|
127
|
+
*
|
|
128
|
+
* ## Examples
|
|
129
|
+
*
|
|
130
|
+
* ```ts
|
|
131
|
+
* // Select cars made before 2000.
|
|
132
|
+
* db.select().from(cars)
|
|
133
|
+
* .where(lt(cars.year, 2000))
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @see lte for greater-than-or-equal
|
|
137
|
+
*/
|
|
138
|
+
declare function lt<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
139
|
+
declare function lt<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
140
|
+
/**
|
|
141
|
+
* Test that the first expression passed is less than
|
|
142
|
+
* or equal to the second expression.
|
|
143
|
+
*
|
|
144
|
+
* ## Examples
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* // Select cars made before 2000.
|
|
148
|
+
* db.select().from(cars)
|
|
149
|
+
* .where(lte(cars.year, 2000))
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @see lt for a strictly less-than condition
|
|
153
|
+
*/
|
|
154
|
+
declare function lte<T>(left: SQL.Aliased<T>, right: T | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
155
|
+
declare function lte<TColumn extends AnyColumn>(left: TColumn, right: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper | AnyColumn): SQL;
|
|
156
|
+
/**
|
|
157
|
+
* Test whether the first parameter, a column or expression,
|
|
158
|
+
* has a value from a list passed as the second argument.
|
|
159
|
+
*
|
|
160
|
+
* ## Throws
|
|
161
|
+
*
|
|
162
|
+
* The argument passed in the second array can’t be empty:
|
|
163
|
+
* if an empty is provided, this method will throw.
|
|
164
|
+
*
|
|
165
|
+
* ## Examples
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* // Select cars made by Ford or GM.
|
|
169
|
+
* db.select().from(cars)
|
|
170
|
+
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @see notInArray for the inverse of this test
|
|
174
|
+
*/
|
|
175
|
+
declare function inArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | Placeholder | SQLWrapper): SQL;
|
|
176
|
+
declare function inArray<TColumn extends AnyColumn>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | Placeholder | SQLWrapper): SQL;
|
|
177
|
+
/**
|
|
178
|
+
* Test whether the first parameter, a column or expression,
|
|
179
|
+
* has a value that is not present in a list passed as the
|
|
180
|
+
* second argument.
|
|
181
|
+
*
|
|
182
|
+
* ## Throws
|
|
183
|
+
*
|
|
184
|
+
* The argument passed in the second array can’t be empty:
|
|
185
|
+
* if an empty is provided, this method will throw.
|
|
186
|
+
*
|
|
187
|
+
* ## Examples
|
|
188
|
+
*
|
|
189
|
+
* ```ts
|
|
190
|
+
* // Select cars made by any company except Ford or GM.
|
|
191
|
+
* db.select().from(cars)
|
|
192
|
+
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @see inArray for the inverse of this test
|
|
196
|
+
*/
|
|
197
|
+
declare function notInArray<T>(column: SQL.Aliased<T>, values: (T | Placeholder)[] | Placeholder | SQLWrapper): SQL;
|
|
198
|
+
declare function notInArray<TColumn extends AnyColumn>(column: TColumn, values: (GetColumnData<TColumn, 'raw'> | Placeholder)[] | Placeholder | SQLWrapper): SQL;
|
|
199
|
+
/**
|
|
200
|
+
* Test whether an expression is NULL. By the SQL standard,
|
|
201
|
+
* NULL is neither equal nor not equal to itself, so
|
|
202
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
203
|
+
* comparisons to NULL.
|
|
204
|
+
*
|
|
205
|
+
* ## Examples
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* // Select cars that have no discontinuedAt date.
|
|
209
|
+
* db.select().from(cars)
|
|
210
|
+
* .where(isNull(cars.discontinuedAt))
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @see isNotNull for the inverse of this test
|
|
214
|
+
*/
|
|
215
|
+
declare function isNull(column: AnyColumn | Placeholder | SQLWrapper): SQL;
|
|
216
|
+
/**
|
|
217
|
+
* Test whether an expression is not NULL. By the SQL standard,
|
|
218
|
+
* NULL is neither equal nor not equal to itself, so
|
|
219
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
220
|
+
* comparisons to NULL.
|
|
221
|
+
*
|
|
222
|
+
* ## Examples
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* // Select cars that have been discontinued.
|
|
226
|
+
* db.select().from(cars)
|
|
227
|
+
* .where(isNotNull(cars.discontinuedAt))
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* @see isNull for the inverse of this test
|
|
231
|
+
*/
|
|
232
|
+
declare function isNotNull(column: AnyColumn | Placeholder | SQLWrapper): SQL;
|
|
233
|
+
/**
|
|
234
|
+
* Test whether a subquery evaluates to have any rows.
|
|
235
|
+
*
|
|
236
|
+
* ## Examples
|
|
237
|
+
*
|
|
238
|
+
* ```ts
|
|
239
|
+
* // Users whose `homeCity` column has a match in a cities
|
|
240
|
+
* // table.
|
|
241
|
+
* db
|
|
242
|
+
* .select()
|
|
243
|
+
* .from(users)
|
|
244
|
+
* .where(
|
|
245
|
+
* exists(db.select()
|
|
246
|
+
* .from(cities)
|
|
247
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
248
|
+
* );
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @see notExists for the inverse of this test
|
|
252
|
+
*/
|
|
253
|
+
declare function exists(subquery: SQLWrapper): SQL;
|
|
254
|
+
/**
|
|
255
|
+
* Test whether a subquery doesn't include any result
|
|
256
|
+
* rows.
|
|
257
|
+
*
|
|
258
|
+
* ## Examples
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* // Users whose `homeCity` column doesn't match
|
|
262
|
+
* // a row in the cities table.
|
|
263
|
+
* db
|
|
264
|
+
* .select()
|
|
265
|
+
* .from(users)
|
|
266
|
+
* .where(
|
|
267
|
+
* notExists(db.select()
|
|
268
|
+
* .from(cities)
|
|
269
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
270
|
+
* );
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @see exists for the inverse of this test
|
|
274
|
+
*/
|
|
275
|
+
declare function notExists(subquery: SQLWrapper): SQL;
|
|
276
|
+
/**
|
|
277
|
+
* Test whether an expression is between two values. This
|
|
278
|
+
* is an easier way to express range tests, which would be
|
|
279
|
+
* expressed mathematically as `x <= a <= y` but in SQL
|
|
280
|
+
* would have to be like `a >= x AND a <= y`.
|
|
281
|
+
*
|
|
282
|
+
* Between is inclusive of the endpoints: if `column`
|
|
283
|
+
* is equal to `min` or `max`, it will be TRUE.
|
|
284
|
+
*
|
|
285
|
+
* ## Examples
|
|
286
|
+
*
|
|
287
|
+
* ```ts
|
|
288
|
+
* // Select cars made between 1990 and 2000
|
|
289
|
+
* db.select().from(cars)
|
|
290
|
+
* .where(between(cars.year, 1990, 2000))
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @see notBetween for the inverse of this test
|
|
294
|
+
*/
|
|
295
|
+
declare function between<T>(column: SQL.Aliased, min: T | Placeholder | SQLWrapper, max: T | Placeholder | SQLWrapper): SQL;
|
|
296
|
+
declare function between<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper): SQL;
|
|
297
|
+
/**
|
|
298
|
+
* Test whether an expression is not between two values.
|
|
299
|
+
*
|
|
300
|
+
* This, like `between`, includes its endpoints, so if
|
|
301
|
+
* the `column` is equal to `min` or `max`, in this case
|
|
302
|
+
* it will evaluate to FALSE.
|
|
303
|
+
*
|
|
304
|
+
* ## Examples
|
|
305
|
+
*
|
|
306
|
+
* ```ts
|
|
307
|
+
* // Exclude cars made in the 1970s
|
|
308
|
+
* db.select().from(cars)
|
|
309
|
+
* .where(notBetween(cars.year, 1970, 1979))
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @see between for the inverse of this test
|
|
313
|
+
*/
|
|
314
|
+
declare function notBetween<T>(column: SQL.Aliased, min: T | Placeholder | SQLWrapper, max: T | Placeholder | SQLWrapper): SQL;
|
|
315
|
+
declare function notBetween<TColumn extends AnyColumn>(column: TColumn, min: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper, max: GetColumnData<TColumn, 'raw'> | Placeholder | SQLWrapper): SQL;
|
|
316
|
+
/**
|
|
317
|
+
* Compare a column to a pattern, which can include `%` and `_`
|
|
318
|
+
* characters to match multiple variations. Including `%`
|
|
319
|
+
* in the pattern matches zero or more characters, and including
|
|
320
|
+
* `_` will match a single character.
|
|
321
|
+
*
|
|
322
|
+
* ## Examples
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* // Select all cars with 'Turbo' in their names.
|
|
326
|
+
* db.select().from(cars)
|
|
327
|
+
* .where(like(cars.name, '%Turbo%'))
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @see ilike for a case-insensitive version of this condition
|
|
331
|
+
*/
|
|
332
|
+
declare function like(column: AnyColumn, value: string | Placeholder | SQLWrapper): SQL;
|
|
333
|
+
/**
|
|
334
|
+
* The inverse of like - this tests that a given column
|
|
335
|
+
* does not match a pattern, which can include `%` and `_`
|
|
336
|
+
* characters to match multiple variations. Including `%`
|
|
337
|
+
* in the pattern matches zero or more characters, and including
|
|
338
|
+
* `_` will match a single character.
|
|
339
|
+
*
|
|
340
|
+
* ## Examples
|
|
341
|
+
*
|
|
342
|
+
* ```ts
|
|
343
|
+
* // Select all cars that don't have "ROver" in their name.
|
|
344
|
+
* db.select().from(cars)
|
|
345
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* @see like for the inverse condition
|
|
349
|
+
* @see notIlike for a case-insensitive version of this condition
|
|
350
|
+
*/
|
|
351
|
+
declare function notLike(column: AnyColumn, value: string | Placeholder | SQLWrapper): SQL;
|
|
352
|
+
/**
|
|
353
|
+
* Case-insensitively compare a column to a pattern,
|
|
354
|
+
* which can include `%` and `_`
|
|
355
|
+
* characters to match multiple variations. Including `%`
|
|
356
|
+
* in the pattern matches zero or more characters, and including
|
|
357
|
+
* `_` will match a single character.
|
|
358
|
+
*
|
|
359
|
+
* Unlike like, this performs a case-insensitive comparison.
|
|
360
|
+
*
|
|
361
|
+
* ## Examples
|
|
362
|
+
*
|
|
363
|
+
* ```ts
|
|
364
|
+
* // Select all cars with 'Turbo' in their names.
|
|
365
|
+
* db.select().from(cars)
|
|
366
|
+
* .where(ilike(cars.name, '%Turbo%'))
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* @see like for a case-sensitive version of this condition
|
|
370
|
+
*/
|
|
371
|
+
declare function ilike(column: AnyColumn, value: string | Placeholder | SQLWrapper): SQL;
|
|
372
|
+
/**
|
|
373
|
+
* The inverse of ilike - this case-insensitively tests that a given column
|
|
374
|
+
* does not match a pattern, which can include `%` and `_`
|
|
375
|
+
* characters to match multiple variations. Including `%`
|
|
376
|
+
* in the pattern matches zero or more characters, and including
|
|
377
|
+
* `_` will match a single character.
|
|
378
|
+
*
|
|
379
|
+
* ## Examples
|
|
380
|
+
*
|
|
381
|
+
* ```ts
|
|
382
|
+
* // Select all cars that don't have "Rover" in their name.
|
|
383
|
+
* db.select().from(cars)
|
|
384
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @see ilike for the inverse condition
|
|
388
|
+
* @see notLike for a case-sensitive version of this condition
|
|
389
|
+
*/
|
|
390
|
+
declare function notIlike(column: AnyColumn, value: string | Placeholder | SQLWrapper): SQL;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Used in sorting, this specifies that the given
|
|
394
|
+
* column or expression should be sorted in ascending
|
|
395
|
+
* order. By the SQL standard, ascending order is the
|
|
396
|
+
* default, so it is not usually necessary to specify
|
|
397
|
+
* ascending sort order.
|
|
398
|
+
*
|
|
399
|
+
* ## Examples
|
|
400
|
+
*
|
|
401
|
+
* ```ts
|
|
402
|
+
* // Return cars, starting with the oldest models
|
|
403
|
+
* // and going in ascending order to the newest.
|
|
404
|
+
* db.select().from(cars)
|
|
405
|
+
* .orderBy(asc(cars.year));
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* @see desc to sort in descending order
|
|
409
|
+
*/
|
|
410
|
+
declare function asc(column: AnyColumn | SQLWrapper): SQL;
|
|
411
|
+
/**
|
|
412
|
+
* Used in sorting, this specifies that the given
|
|
413
|
+
* column or expression should be sorted in descending
|
|
414
|
+
* order.
|
|
415
|
+
*
|
|
416
|
+
* ## Examples
|
|
417
|
+
*
|
|
418
|
+
* ```ts
|
|
419
|
+
* // Select users, with the most recently created
|
|
420
|
+
* // records coming first.
|
|
421
|
+
* db.select().from(users)
|
|
422
|
+
* .orderBy(desc(users.createdAt));
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @see asc to sort in ascending order
|
|
426
|
+
*/
|
|
427
|
+
declare function desc(column: AnyColumn | SQLWrapper): SQL;
|
|
428
|
+
|
|
429
|
+
declare abstract class Relation<TTableName extends string = string> {
|
|
430
|
+
readonly sourceTable: Table;
|
|
431
|
+
readonly referencedTable: AnyTable<{
|
|
432
|
+
name: TTableName;
|
|
433
|
+
}>;
|
|
434
|
+
readonly relationName: string | undefined;
|
|
435
|
+
readonly $brand: 'Relation';
|
|
436
|
+
readonly referencedTableName: TTableName;
|
|
437
|
+
fieldName: string;
|
|
438
|
+
constructor(sourceTable: Table, referencedTable: AnyTable<{
|
|
439
|
+
name: TTableName;
|
|
440
|
+
}>, relationName: string | undefined);
|
|
441
|
+
abstract withFieldName(fieldName: string): Relation<TTableName>;
|
|
442
|
+
}
|
|
443
|
+
declare class Relations<TTableName extends string = string, TConfig extends Record<string, Relation> = Record<string, Relation>> {
|
|
444
|
+
readonly table: AnyTable<{
|
|
445
|
+
name: TTableName;
|
|
446
|
+
}>;
|
|
447
|
+
readonly config: (helpers: TableRelationsHelpers<TTableName>) => TConfig;
|
|
448
|
+
readonly $brand: 'Relations';
|
|
449
|
+
constructor(table: AnyTable<{
|
|
450
|
+
name: TTableName;
|
|
451
|
+
}>, config: (helpers: TableRelationsHelpers<TTableName>) => TConfig);
|
|
452
|
+
}
|
|
453
|
+
declare class One<TTableName extends string = string, TIsNullable extends boolean = boolean> extends Relation<TTableName> {
|
|
454
|
+
readonly config: RelationConfig<TTableName, string, AnyColumn<{
|
|
455
|
+
tableName: TTableName;
|
|
456
|
+
}>[]> | undefined;
|
|
457
|
+
readonly isNullable: TIsNullable;
|
|
458
|
+
protected $relationBrand: 'One';
|
|
459
|
+
constructor(sourceTable: Table, referencedTable: AnyTable<{
|
|
460
|
+
name: TTableName;
|
|
461
|
+
}>, config: RelationConfig<TTableName, string, AnyColumn<{
|
|
462
|
+
tableName: TTableName;
|
|
463
|
+
}>[]> | undefined, isNullable: TIsNullable);
|
|
464
|
+
withFieldName(fieldName: string): One<TTableName>;
|
|
465
|
+
}
|
|
466
|
+
declare class Many<TTableName extends string> extends Relation<TTableName> {
|
|
467
|
+
readonly config: {
|
|
468
|
+
relationName: string;
|
|
469
|
+
} | undefined;
|
|
470
|
+
protected $relationBrand: 'Many';
|
|
471
|
+
constructor(sourceTable: Table, referencedTable: AnyTable<{
|
|
472
|
+
name: TTableName;
|
|
473
|
+
}>, config: {
|
|
474
|
+
relationName: string;
|
|
475
|
+
} | undefined);
|
|
476
|
+
withFieldName(fieldName: string): Many<TTableName>;
|
|
477
|
+
}
|
|
478
|
+
type TableRelationsKeysOnly<TSchema extends Record<string, unknown>, TTableName extends string, K extends keyof TSchema> = TSchema[K] extends Relations<TTableName> ? K : never;
|
|
479
|
+
type ExtractTableRelationsFromSchema<TSchema extends Record<string, unknown>, TTableName extends string> = ExtractObjectValues<{
|
|
480
|
+
[K in keyof TSchema as TableRelationsKeysOnly<TSchema, TTableName, K>]: TSchema[K] extends Relations<TTableName, infer TConfig> ? TConfig : never;
|
|
481
|
+
}>;
|
|
482
|
+
type ExtractObjectValues<T> = T[keyof T];
|
|
483
|
+
type ExtractRelationsFromTableExtraConfigSchema<TConfig extends unknown[]> = ExtractObjectValues<{
|
|
484
|
+
[K in keyof TConfig as TConfig[K] extends Relations<any> ? K : never]: TConfig[K] extends Relations<infer TRelationConfig> ? TRelationConfig : never;
|
|
485
|
+
}>;
|
|
486
|
+
declare const operators: {
|
|
487
|
+
sql: typeof sql;
|
|
488
|
+
eq: typeof eq;
|
|
489
|
+
and: typeof and;
|
|
490
|
+
or: typeof or;
|
|
491
|
+
};
|
|
492
|
+
type Operators = typeof operators;
|
|
493
|
+
declare const orderByOperators: {
|
|
494
|
+
sql: typeof sql;
|
|
495
|
+
asc: typeof asc;
|
|
496
|
+
desc: typeof desc;
|
|
497
|
+
};
|
|
498
|
+
type OrderByOperators = typeof orderByOperators;
|
|
499
|
+
type FindTableByDBName<TSchema extends TablesRelationalConfig, TTableName extends string> = ExtractObjectValues<{
|
|
500
|
+
[K in keyof TSchema as TSchema[K]['dbName'] extends TTableName ? K : never]: TSchema[K];
|
|
501
|
+
}>;
|
|
502
|
+
type DBQueryConfig<TRelationType extends 'one' | 'many' = 'one' | 'many', TIsRoot extends boolean = boolean, TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableConfig extends TableRelationalConfig = TableRelationalConfig> = {
|
|
503
|
+
columns?: {
|
|
504
|
+
[K in keyof TTableConfig['columns']]?: boolean;
|
|
505
|
+
};
|
|
506
|
+
with?: {
|
|
507
|
+
[K in keyof TTableConfig['relations']]?: true | DBQueryConfig<TTableConfig['relations'][K] extends One ? 'one' : 'many', false, TSchema, FindTableByDBName<TSchema, TTableConfig['relations'][K]['referencedTableName']>>;
|
|
508
|
+
};
|
|
509
|
+
extras?: Record<string, SQL.Aliased> | ((fields: SimplifyShallow<TTableConfig['columns'] & TTableConfig['relations']>, operators: {
|
|
510
|
+
sql: Operators['sql'];
|
|
511
|
+
}) => Record<string, SQL.Aliased>);
|
|
512
|
+
} & (TRelationType extends 'many' ? {
|
|
513
|
+
where?: SQL | undefined | ((fields: SimplifyShallow<TTableConfig['columns'] & TTableConfig['relations']>, operators: Operators) => SQL | undefined);
|
|
514
|
+
orderBy?: ValueOrArray<AnyColumn | SQL> | ((fields: SimplifyShallow<TTableConfig['columns'] & TTableConfig['relations']>, operators: OrderByOperators) => ValueOrArray<AnyColumn | SQL>);
|
|
515
|
+
limit?: number | Placeholder;
|
|
516
|
+
} & (TIsRoot extends true ? {
|
|
517
|
+
offset?: number | Placeholder;
|
|
518
|
+
} : {}) : {});
|
|
519
|
+
interface TableRelationalConfig {
|
|
520
|
+
tsName: string;
|
|
521
|
+
dbName: string;
|
|
522
|
+
columns: Record<string, AnyColumn>;
|
|
523
|
+
relations: Record<string, Relation>;
|
|
524
|
+
primaryKey: AnyColumn[];
|
|
525
|
+
}
|
|
526
|
+
type TablesRelationalConfig = Record<string, TableRelationalConfig>;
|
|
527
|
+
interface RelationalSchemaConfig<TSchema extends TablesRelationalConfig> {
|
|
528
|
+
fullSchema: Record<string, unknown>;
|
|
529
|
+
schema: TSchema;
|
|
530
|
+
tableNamesMap: Record<string, string>;
|
|
531
|
+
}
|
|
532
|
+
type ExtractTablesWithRelations<TSchema extends Record<string, unknown>> = {
|
|
533
|
+
[K in keyof TSchema as TSchema[K] extends Table ? K : never]: TSchema[K] extends Table ? {
|
|
534
|
+
tsName: K & string;
|
|
535
|
+
dbName: TSchema[K]['_']['name'];
|
|
536
|
+
columns: TSchema[K]['_']['columns'];
|
|
537
|
+
relations: ExtractTableRelationsFromSchema<TSchema, TSchema[K]['_']['name']>;
|
|
538
|
+
primaryKey: AnyColumn[];
|
|
539
|
+
} : never;
|
|
540
|
+
};
|
|
541
|
+
type ReturnTypeOrValue<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
542
|
+
type BuildRelationResult<TSchema extends TablesRelationalConfig, TInclude, TRelations extends Record<string, Relation>> = {
|
|
543
|
+
[K in NonUndefinedKeysOnly<TInclude> & keyof TRelations]: TRelations[K] extends infer TRel extends Relation ? BuildQueryResult<TSchema, FindTableByDBName<TSchema, TRel['referencedTableName']>, Assume<TInclude[K], true | Record<string, unknown>>> extends infer TResult ? TRel extends One ? (TResult | (Equal<TRel['isNullable'], false> extends true ? null : never)) : TResult[] : never : never;
|
|
544
|
+
};
|
|
545
|
+
type NonUndefinedKeysOnly<T> = ExtractObjectValues<{
|
|
546
|
+
[K in keyof T as T[K] extends undefined ? never : K]: K;
|
|
547
|
+
}> & keyof T;
|
|
548
|
+
type BuildQueryResult<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TFullSelection extends true | Record<string, unknown>> = Equal<TFullSelection, true> extends true ? InferModelFromColumns<TTableConfig['columns']> : TFullSelection extends Record<string, unknown> ? (SimplifyShallow<(TFullSelection['columns'] extends Record<string, unknown> ? InferModelFromColumns<{
|
|
549
|
+
[K in (Equal<Exclude<TFullSelection['columns'][keyof TFullSelection['columns'] & keyof TTableConfig['columns']], undefined>, false> extends true ? Exclude<keyof TTableConfig['columns'], NonUndefinedKeysOnly<TFullSelection['columns']>> : {
|
|
550
|
+
[K in keyof TFullSelection['columns']]: Equal<TFullSelection['columns'][K], true> extends true ? K : never;
|
|
551
|
+
}[keyof TFullSelection['columns']] & keyof TTableConfig['columns'])]: TTableConfig['columns'][K];
|
|
552
|
+
}> : InferModelFromColumns<TTableConfig['columns']>) & (TFullSelection['extras'] extends Record<string, unknown> | ((...args: any[]) => Record<string, unknown>) ? {
|
|
553
|
+
[K in NonUndefinedKeysOnly<ReturnTypeOrValue<TFullSelection['extras']>>]: Assume<ReturnTypeOrValue<TFullSelection['extras']>[K], SQL.Aliased>['_']['type'];
|
|
554
|
+
} : {}) & (TFullSelection['with'] extends Record<string, unknown> ? BuildRelationResult<TSchema, TFullSelection['with'], TTableConfig['relations']> : {})>) : never;
|
|
555
|
+
interface RelationConfig<TTableName extends string, TForeignTableName extends string, TColumns extends AnyColumn<{
|
|
556
|
+
tableName: TTableName;
|
|
557
|
+
}>[]> {
|
|
558
|
+
relationName?: string;
|
|
559
|
+
fields: TColumns;
|
|
560
|
+
references: ColumnsWithTable<TTableName, TForeignTableName, TColumns>;
|
|
561
|
+
}
|
|
562
|
+
declare function extractTablesRelationalConfig<TTables extends TablesRelationalConfig>(schema: Record<string, unknown>, configHelpers: (table: Table) => any): {
|
|
563
|
+
tables: TTables;
|
|
564
|
+
tableNamesMap: Record<string, string>;
|
|
565
|
+
};
|
|
566
|
+
declare function relations<TTableName extends string, TRelations extends Record<string, Relation<any>>>(table: AnyTable<{
|
|
567
|
+
name: TTableName;
|
|
568
|
+
}>, relations: (helpers: TableRelationsHelpers<TTableName>) => TRelations): Relations<TTableName, TRelations>;
|
|
569
|
+
declare function createOne<TTableName extends string>(sourceTable: Table): <TForeignTable extends Table<TableConfig<AnyColumn>>, TColumns extends [AnyColumn<{
|
|
570
|
+
tableName: TTableName;
|
|
571
|
+
}>, ...AnyColumn<{
|
|
572
|
+
tableName: TTableName;
|
|
573
|
+
}>[]]>(table: TForeignTable, config?: RelationConfig<TTableName, TForeignTable["_"]["name"], TColumns> | undefined) => One<TForeignTable["_"]["name"], Equal<TColumns[number]["_"]["notNull"], true>>;
|
|
574
|
+
declare function createMany(sourceTable: Table): <TForeignTable extends Table<TableConfig<AnyColumn>>>(referencedTable: TForeignTable, config?: {
|
|
575
|
+
relationName: string;
|
|
576
|
+
}) => Many<TForeignTable["_"]["name"]>;
|
|
577
|
+
interface NormalizedRelation {
|
|
578
|
+
fields: AnyColumn[];
|
|
579
|
+
references: AnyColumn[];
|
|
580
|
+
}
|
|
581
|
+
declare function normalizeRelation(schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, relation: Relation): NormalizedRelation;
|
|
582
|
+
declare function createTableRelationsHelpers<TTableName extends string>(sourceTable: AnyTable<{
|
|
583
|
+
name: TTableName;
|
|
584
|
+
}>): {
|
|
585
|
+
one: <TForeignTable extends Table<TableConfig<AnyColumn>>, TColumns extends [AnyColumn<{
|
|
586
|
+
tableName: TTableName;
|
|
587
|
+
}>, ...AnyColumn<{
|
|
588
|
+
tableName: TTableName;
|
|
589
|
+
}>[]]>(table: TForeignTable, config?: RelationConfig<TTableName, TForeignTable["_"]["name"], TColumns> | undefined) => One<TForeignTable["_"]["name"], Equal<TColumns[number]["_"]["notNull"], true>>;
|
|
590
|
+
many: <TForeignTable_1 extends Table<TableConfig<AnyColumn>>>(referencedTable: TForeignTable_1, config?: {
|
|
591
|
+
relationName: string;
|
|
592
|
+
} | undefined) => Many<TForeignTable_1["_"]["name"]>;
|
|
593
|
+
};
|
|
594
|
+
type TableRelationsHelpers<TTableName extends string> = ReturnType<typeof createTableRelationsHelpers<TTableName>>;
|
|
595
|
+
interface BuildRelationalQueryResult {
|
|
596
|
+
tableTsKey: string;
|
|
597
|
+
selection: {
|
|
598
|
+
dbKey: string;
|
|
599
|
+
tsKey: string;
|
|
600
|
+
field: AnyColumn | SQL | SQL.Aliased | undefined;
|
|
601
|
+
tableTsKey: string | undefined;
|
|
602
|
+
isJson: boolean;
|
|
603
|
+
selection: BuildRelationalQueryResult['selection'];
|
|
604
|
+
}[];
|
|
605
|
+
sql: SQL;
|
|
606
|
+
}
|
|
607
|
+
declare function mapRelationalRow(tablesConfig: TablesRelationalConfig, tableConfig: TableRelationalConfig, row: unknown[], buildQueryResultSelection: BuildRelationalQueryResult['selection'], jsonParseRelationalFields?: boolean, mapColumnValue?: (value: unknown) => unknown): Record<string, unknown>;
|
|
608
|
+
|
|
609
|
+
declare abstract class QueryPromise<T> implements Promise<T> {
|
|
610
|
+
[Symbol.toStringTag]: string;
|
|
611
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
|
|
612
|
+
finally(onFinally?: (() => void) | null | undefined): Promise<T>;
|
|
613
|
+
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
614
|
+
abstract execute(): Promise<T>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export { normalizeRelation as $, ExtractRelationsFromTableExtraConfigSchema as A, operators as B, Operators as C, orderByOperators as D, ExtractTableRelationsFromSchema as E, OrderByOperators as F, FindTableByDBName as G, DBQueryConfig as H, TableRelationalConfig as I, TablesRelationalConfig as J, RelationalSchemaConfig as K, ExtractTablesWithRelations as L, Many as M, ReturnTypeOrValue as N, One as O, BuildRelationResult as P, QueryPromise as Q, Relation as R, NonUndefinedKeysOnly as S, TableRelationsKeysOnly as T, BuildQueryResult as U, RelationConfig as V, extractTablesRelationalConfig as W, relations as X, createOne as Y, createMany as Z, NormalizedRelation as _, and as a, createTableRelationsHelpers as a0, TableRelationsHelpers as a1, BuildRelationalQueryResult as a2, mapRelationalRow as a3, bindIfParam as b, not as c, gte as d, eq as e, lte as f, gt as g, notInArray as h, inArray as i, isNull as j, isNotNull as k, lt as l, exists as m, ne as n, or as o, notExists as p, between as q, notBetween as r, like as s, notLike as t, ilike as u, notIlike as v, asc as w, desc as x, Relations as y, ExtractObjectValues as z };
|