kysely 0.11.1 → 0.12.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/README.md +1 -1
- package/dist/cjs/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/cjs/dialect/mysql/mysql-query-compiler.js +0 -6
- package/dist/cjs/dialect/postgres/postgres-query-compiler.d.ts +3 -0
- package/dist/cjs/dialect/postgres/postgres-query-compiler.js +9 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.js +6 -2
- package/dist/cjs/dialect/sqlite/sqlite-driver.js +7 -7
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.d.ts +2 -2
- package/dist/cjs/dialect/sqlite/sqlite-query-compiler.js +6 -6
- package/dist/cjs/driver/runtime-driver.js +1 -1
- package/dist/cjs/dynamic/dynamic-reference-builder.d.ts +1 -0
- package/dist/cjs/dynamic/dynamic-reference-builder.js +9 -1
- package/dist/cjs/dynamic/dynamic.d.ts +6 -7
- package/dist/cjs/dynamic/dynamic.js +6 -7
- package/dist/cjs/index.d.ts +51 -33
- package/dist/cjs/index.js +48 -30
- package/dist/cjs/kysely.d.ts +39 -15
- package/dist/cjs/kysely.js +32 -9
- package/dist/cjs/migration/migration.d.ts +2 -2
- package/dist/cjs/operation-node/alias-node.d.ts +1 -1
- package/dist/cjs/operation-node/create-table-node.d.ts +6 -2
- package/dist/cjs/operation-node/create-table-node.js +6 -6
- package/dist/cjs/operation-node/create-view-node.d.ts +1 -0
- package/dist/cjs/operation-node/insert-query-node.d.ts +4 -4
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +11 -1
- package/dist/cjs/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/query-node.d.ts +0 -2
- package/dist/cjs/operation-node/query-node.js +0 -10
- package/dist/cjs/operation-node/values-node.d.ts +15 -0
- package/dist/cjs/operation-node/values-node.js +18 -0
- package/dist/cjs/parser/complex-expression-parser.d.ts +9 -0
- package/dist/cjs/parser/complex-expression-parser.js +25 -0
- package/dist/cjs/parser/filter-parser.d.ts +13 -3
- package/dist/cjs/parser/filter-parser.js +56 -62
- package/dist/cjs/parser/insert-values-parser.d.ts +7 -10
- package/dist/cjs/parser/insert-values-parser.js +31 -39
- package/dist/cjs/parser/order-by-parser.d.ts +1 -1
- package/dist/cjs/parser/parse-context.d.ts +8 -8
- package/dist/cjs/parser/parse-context.js +10 -10
- package/dist/cjs/parser/reference-parser.d.ts +8 -7
- package/dist/cjs/parser/reference-parser.js +8 -17
- package/dist/cjs/parser/returning-parser.d.ts +1 -5
- package/dist/cjs/parser/select-parser.d.ts +12 -14
- package/dist/cjs/parser/select-parser.js +5 -9
- package/dist/cjs/parser/table-parser.d.ts +9 -11
- package/dist/cjs/parser/table-parser.js +2 -8
- package/dist/cjs/parser/union-parser.d.ts +2 -2
- package/dist/cjs/parser/union-parser.js +1 -6
- package/dist/cjs/parser/update-set-parser.d.ts +2 -8
- package/dist/cjs/parser/update-set-parser.js +6 -26
- package/dist/cjs/parser/value-parser.d.ts +9 -6
- package/dist/cjs/parser/value-parser.js +7 -30
- package/dist/cjs/parser/with-parser.d.ts +6 -3
- package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/cjs/query-builder/delete-query-builder.d.ts +102 -0
- package/dist/cjs/query-builder/delete-query-builder.js +185 -0
- package/dist/cjs/query-builder/expression-builder.d.ts +8 -6
- package/dist/cjs/query-builder/expression-builder.js +3 -3
- package/dist/cjs/query-builder/function-builder.d.ts +2 -1
- package/dist/cjs/query-builder/function-builder.js +2 -1
- package/dist/cjs/query-builder/having-interface.d.ts +49 -0
- package/dist/cjs/query-builder/having-interface.js +2 -0
- package/dist/cjs/query-builder/insert-query-builder.d.ts +439 -0
- package/dist/cjs/query-builder/insert-query-builder.js +256 -0
- package/dist/cjs/query-builder/insert-result.d.ts +3 -2
- package/dist/cjs/query-builder/insert-result.js +3 -2
- package/dist/cjs/query-builder/join-builder.d.ts +22 -20
- package/dist/cjs/query-builder/join-builder.js +12 -12
- package/dist/cjs/query-builder/join-interface.d.ts +133 -0
- package/dist/cjs/query-builder/join-interface.js +2 -0
- package/dist/cjs/query-builder/no-result-error.d.ts +9 -0
- package/dist/cjs/query-builder/no-result-error.js +14 -0
- package/dist/cjs/query-builder/returning-interface.d.ts +73 -0
- package/dist/cjs/query-builder/returning-interface.js +2 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +711 -0
- package/dist/cjs/query-builder/select-query-builder.js +571 -0
- package/dist/cjs/query-builder/update-query-builder.d.ts +190 -0
- package/dist/cjs/query-builder/update-query-builder.js +279 -0
- package/dist/cjs/query-builder/where-interface.d.ts +381 -0
- package/dist/cjs/query-builder/where-interface.js +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +22 -5
- package/dist/cjs/query-creator.d.ts +42 -40
- package/dist/cjs/query-creator.js +33 -28
- package/dist/cjs/query-executor/query-executor.d.ts +1 -1
- package/dist/cjs/query-executor/query-executor.js +1 -1
- package/dist/cjs/raw-builder/raw-builder.d.ts +2 -0
- package/dist/cjs/raw-builder/raw-builder.js +6 -0
- package/dist/cjs/schema/alter-table-builder.d.ts +2 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +27 -20
- package/dist/cjs/schema/create-index-builder.d.ts +2 -1
- package/dist/cjs/schema/create-index-builder.js +2 -1
- package/dist/cjs/schema/create-table-builder.d.ts +26 -9
- package/dist/cjs/schema/create-table-builder.js +42 -9
- package/dist/cjs/schema/create-view-builder.d.ts +17 -3
- package/dist/cjs/schema/create-view-builder.js +25 -16
- package/dist/cjs/schema/schema.d.ts +18 -11
- package/dist/cjs/schema/schema.js +18 -11
- package/dist/cjs/util/dynamic-import.js +1 -1
- package/dist/cjs/util/log.d.ts +11 -8
- package/dist/cjs/util/log.js +25 -12
- package/dist/cjs/util/type-utils.d.ts +7 -7
- package/dist/esm/dialect/mysql/mysql-query-compiler.d.ts +0 -2
- package/dist/esm/dialect/mysql/mysql-query-compiler.js +0 -6
- package/dist/esm/dialect/postgres/postgres-query-compiler.d.ts +3 -0
- package/dist/esm/dialect/postgres/postgres-query-compiler.js +9 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.js +6 -2
- package/dist/esm/dialect/sqlite/sqlite-driver.js +7 -7
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.d.ts +2 -2
- package/dist/esm/dialect/sqlite/sqlite-query-compiler.js +6 -6
- package/dist/esm/driver/runtime-driver.js +1 -1
- package/dist/esm/dynamic/dynamic-reference-builder.d.ts +1 -0
- package/dist/esm/dynamic/dynamic-reference-builder.js +7 -0
- package/dist/esm/dynamic/dynamic.d.ts +6 -7
- package/dist/esm/dynamic/dynamic.js +6 -7
- package/dist/esm/index.d.ts +51 -33
- package/dist/esm/index.js +48 -30
- package/dist/esm/kysely.d.ts +39 -15
- package/dist/esm/kysely.js +32 -9
- package/dist/esm/migration/migration.d.ts +2 -2
- package/dist/esm/operation-node/alias-node.d.ts +1 -1
- package/dist/esm/operation-node/create-table-node.d.ts +6 -2
- package/dist/esm/operation-node/create-table-node.js +6 -6
- package/dist/esm/operation-node/create-view-node.d.ts +1 -0
- package/dist/esm/operation-node/insert-query-node.d.ts +4 -4
- package/dist/esm/operation-node/operation-node-transformer.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-transformer.js +11 -1
- package/dist/esm/operation-node/operation-node-utils.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
- package/dist/esm/operation-node/operation-node-visitor.js +1 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/query-node.d.ts +0 -2
- package/dist/esm/operation-node/query-node.js +0 -10
- package/dist/esm/operation-node/values-node.d.ts +15 -0
- package/dist/esm/operation-node/values-node.js +15 -0
- package/dist/esm/parser/complex-expression-parser.d.ts +9 -0
- package/dist/esm/parser/complex-expression-parser.js +20 -0
- package/dist/esm/parser/filter-parser.d.ts +13 -3
- package/dist/esm/parser/filter-parser.js +55 -62
- package/dist/esm/parser/insert-values-parser.d.ts +7 -10
- package/dist/esm/parser/insert-values-parser.js +31 -38
- package/dist/esm/parser/order-by-parser.d.ts +1 -1
- package/dist/esm/parser/parse-context.d.ts +8 -8
- package/dist/esm/parser/parse-context.js +10 -10
- package/dist/esm/parser/reference-parser.d.ts +8 -7
- package/dist/esm/parser/reference-parser.js +9 -18
- package/dist/esm/parser/returning-parser.d.ts +1 -5
- package/dist/esm/parser/select-parser.d.ts +12 -14
- package/dist/esm/parser/select-parser.js +6 -10
- package/dist/esm/parser/table-parser.d.ts +9 -11
- package/dist/esm/parser/table-parser.js +3 -9
- package/dist/esm/parser/union-parser.d.ts +2 -2
- package/dist/esm/parser/union-parser.js +1 -6
- package/dist/esm/parser/update-set-parser.d.ts +2 -8
- package/dist/esm/parser/update-set-parser.js +5 -24
- package/dist/esm/parser/value-parser.d.ts +9 -6
- package/dist/esm/parser/value-parser.js +8 -31
- package/dist/esm/parser/with-parser.d.ts +6 -3
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/esm/query-builder/delete-query-builder.d.ts +102 -0
- package/dist/esm/query-builder/delete-query-builder.js +181 -0
- package/dist/esm/query-builder/expression-builder.d.ts +8 -6
- package/dist/esm/query-builder/expression-builder.js +3 -3
- package/dist/esm/query-builder/function-builder.d.ts +2 -1
- package/dist/esm/query-builder/function-builder.js +2 -1
- package/dist/esm/query-builder/having-interface.d.ts +49 -0
- package/dist/esm/query-builder/having-interface.js +1 -0
- package/dist/esm/query-builder/insert-query-builder.d.ts +439 -0
- package/dist/esm/query-builder/insert-query-builder.js +252 -0
- package/dist/esm/query-builder/insert-result.d.ts +3 -2
- package/dist/esm/query-builder/insert-result.js +3 -2
- package/dist/esm/query-builder/join-builder.d.ts +22 -20
- package/dist/esm/query-builder/join-builder.js +12 -12
- package/dist/esm/query-builder/join-interface.d.ts +133 -0
- package/dist/esm/query-builder/join-interface.js +1 -0
- package/dist/esm/query-builder/no-result-error.d.ts +9 -0
- package/dist/esm/query-builder/no-result-error.js +10 -0
- package/dist/esm/query-builder/returning-interface.d.ts +73 -0
- package/dist/esm/query-builder/returning-interface.js +1 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +711 -0
- package/dist/esm/query-builder/select-query-builder.js +566 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +190 -0
- package/dist/esm/query-builder/update-query-builder.js +275 -0
- package/dist/esm/query-builder/where-interface.d.ts +381 -0
- package/dist/esm/query-builder/where-interface.js +1 -0
- package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +22 -5
- package/dist/esm/query-creator.d.ts +42 -40
- package/dist/esm/query-creator.js +33 -28
- package/dist/esm/query-executor/query-executor.d.ts +1 -1
- package/dist/esm/query-executor/query-executor.js +1 -1
- package/dist/esm/raw-builder/raw-builder.d.ts +2 -0
- package/dist/esm/raw-builder/raw-builder.js +6 -0
- package/dist/esm/schema/alter-table-builder.d.ts +2 -2
- package/dist/esm/schema/column-definition-builder.d.ts +27 -20
- package/dist/esm/schema/create-index-builder.d.ts +2 -1
- package/dist/esm/schema/create-index-builder.js +2 -1
- package/dist/esm/schema/create-table-builder.d.ts +26 -9
- package/dist/esm/schema/create-table-builder.js +43 -10
- package/dist/esm/schema/create-view-builder.d.ts +17 -3
- package/dist/esm/schema/create-view-builder.js +25 -16
- package/dist/esm/schema/schema.d.ts +18 -11
- package/dist/esm/schema/schema.js +18 -11
- package/dist/esm/util/dynamic-import.js +1 -1
- package/dist/esm/util/log.d.ts +11 -8
- package/dist/esm/util/log.js +25 -12
- package/dist/esm/util/type-utils.d.ts +7 -7
- package/package.json +3 -3
- package/dist/cjs/query-builder/query-builder.d.ts +0 -1707
- package/dist/cjs/query-builder/query-builder.js +0 -1067
- package/dist/esm/query-builder/query-builder.d.ts +0 -1707
- package/dist/esm/query-builder/query-builder.js +0 -1061
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SelectQueryBuilder } from './query-builder/select-query-builder.js';
|
|
2
|
+
import { InsertQueryBuilder } from './query-builder/insert-query-builder.js';
|
|
3
|
+
import { DeleteQueryBuilder } from './query-builder/delete-query-builder.js';
|
|
4
|
+
import { UpdateQueryBuilder } from './query-builder/update-query-builder.js';
|
|
5
|
+
import { TableExpression, TableExpressionDatabase, TableExpressionTables, TableReference } from './parser/table-parser.js';
|
|
3
6
|
import { QueryExecutor } from './query-executor/query-executor.js';
|
|
4
7
|
import { RawBuilder } from './raw-builder/raw-builder.js';
|
|
5
8
|
import { CommonTableExpression, QueryCreatorWithCommonTableExpression } from './parser/with-parser.js';
|
|
@@ -16,7 +19,8 @@ export declare class QueryCreator<DB> {
|
|
|
16
19
|
*
|
|
17
20
|
* The tables passed to this method are built as the query's `from` clause.
|
|
18
21
|
*
|
|
19
|
-
*
|
|
22
|
+
* ### Examples
|
|
23
|
+
*
|
|
20
24
|
* Create a select query for one table:
|
|
21
25
|
*
|
|
22
26
|
* ```ts
|
|
@@ -29,12 +33,11 @@ export declare class QueryCreator<DB> {
|
|
|
29
33
|
* select * from "person"
|
|
30
34
|
* ```
|
|
31
35
|
*
|
|
32
|
-
* @example
|
|
33
36
|
* Create a select query for one table with an alias:
|
|
34
37
|
*
|
|
35
38
|
* ```ts
|
|
36
39
|
* const persons = await db.selectFrom('person as p')
|
|
37
|
-
* .select(['p.id', '
|
|
40
|
+
* .select(['p.id', 'first_name'])
|
|
38
41
|
* .execute()
|
|
39
42
|
*
|
|
40
43
|
* console.log(persons[0].id)
|
|
@@ -43,15 +46,14 @@ export declare class QueryCreator<DB> {
|
|
|
43
46
|
* The generated SQL (PostgreSQL):
|
|
44
47
|
*
|
|
45
48
|
* ```sql
|
|
46
|
-
* select "p"."id", "
|
|
49
|
+
* select "p"."id", "first_name" from "person" as "p"
|
|
47
50
|
* ```
|
|
48
51
|
*
|
|
49
|
-
* @example
|
|
50
52
|
* Create a select query from a subquery:
|
|
51
53
|
*
|
|
52
54
|
* ```ts
|
|
53
55
|
* const persons = await db.selectFrom(
|
|
54
|
-
*
|
|
56
|
+
* (eb) => eb.selectFrom('person').select('person.id as identifier').as('p')
|
|
55
57
|
* )
|
|
56
58
|
* .select('p.identifier')
|
|
57
59
|
* .execute()
|
|
@@ -68,12 +70,11 @@ export declare class QueryCreator<DB> {
|
|
|
68
70
|
* ) as p
|
|
69
71
|
* ```
|
|
70
72
|
*
|
|
71
|
-
* @example
|
|
72
73
|
* Create a select query from raw sql:
|
|
73
74
|
*
|
|
74
75
|
* ```ts
|
|
75
76
|
* const items = await db.selectFrom(
|
|
76
|
-
* db.raw<{
|
|
77
|
+
* db.raw<{ one: number }>('(select 1 as one)').as('q')
|
|
77
78
|
* )
|
|
78
79
|
* .select('q.one')
|
|
79
80
|
* .execute()
|
|
@@ -94,7 +95,6 @@ export declare class QueryCreator<DB> {
|
|
|
94
95
|
* raw segment / query so that Kysely can figure out what columns are
|
|
95
96
|
* available for the query.
|
|
96
97
|
*
|
|
97
|
-
* @example
|
|
98
98
|
* The `selectFrom` method also accepts an array for multiple tables. All
|
|
99
99
|
* the above examples can also be used in an array.
|
|
100
100
|
*
|
|
@@ -102,7 +102,7 @@ export declare class QueryCreator<DB> {
|
|
|
102
102
|
* const items = await db.selectFrom([
|
|
103
103
|
* 'person as p',
|
|
104
104
|
* db.selectFrom('pet').select('pet.species').as('a'),
|
|
105
|
-
* db.raw<{
|
|
105
|
+
* db.raw<{ one: number }>('(select 1 as one)').as('q')
|
|
106
106
|
* ])
|
|
107
107
|
* .select(['p.id', 'a.species', 'q.one'])
|
|
108
108
|
* .execute()
|
|
@@ -118,20 +118,21 @@ export declare class QueryCreator<DB> {
|
|
|
118
118
|
* (select 1 as one) as "q"
|
|
119
119
|
* ```
|
|
120
120
|
*/
|
|
121
|
-
selectFrom<
|
|
122
|
-
selectFrom<
|
|
121
|
+
selectFrom<TE extends TableExpression<DB, keyof DB>>(from: TE[]): SelectQueryBuilder<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, never, TE>, {}>;
|
|
122
|
+
selectFrom<TE extends TableExpression<DB, keyof DB>>(from: TE): SelectQueryBuilder<TableExpressionDatabase<DB, TE>, TableExpressionTables<DB, never, TE>, {}>;
|
|
123
123
|
/**
|
|
124
124
|
* Creates an insert query.
|
|
125
125
|
*
|
|
126
126
|
* The return value of this query is an instance of {@link InsertResult}. {@link InsertResult}
|
|
127
|
-
* has the {@link InsertResult.insertId |
|
|
127
|
+
* has the {@link InsertResult.insertId | insertId} field that holds the auto incremented id of
|
|
128
128
|
* the inserted row if the db returned one.
|
|
129
129
|
*
|
|
130
|
-
* See the {@link
|
|
131
|
-
* the {@link
|
|
130
|
+
* See the {@link InsertQueryBuilder.values | values} method for more info and examples. Also see
|
|
131
|
+
* the {@link ReturningInterface.returning | returning} method for a way to return columns
|
|
132
132
|
* on supported databases like PostgreSQL.
|
|
133
133
|
*
|
|
134
|
-
*
|
|
134
|
+
* ### Examples
|
|
135
|
+
*
|
|
135
136
|
* ```ts
|
|
136
137
|
* const result = await db
|
|
137
138
|
* .insertInto('person')
|
|
@@ -145,11 +146,10 @@ export declare class QueryCreator<DB> {
|
|
|
145
146
|
* console.log(result.insertId)
|
|
146
147
|
* ```
|
|
147
148
|
*
|
|
148
|
-
* @example
|
|
149
149
|
* Some databases like PostgreSQL support the `returning` method:
|
|
150
150
|
*
|
|
151
151
|
* ```ts
|
|
152
|
-
* const {
|
|
152
|
+
* const { id } = await db
|
|
153
153
|
* .insertInto('person')
|
|
154
154
|
* .values({
|
|
155
155
|
* id: db.generated,
|
|
@@ -160,16 +160,17 @@ export declare class QueryCreator<DB> {
|
|
|
160
160
|
* .executeTakeFirst()
|
|
161
161
|
* ```
|
|
162
162
|
*/
|
|
163
|
-
insertInto<T extends keyof DB & string>(table: T):
|
|
163
|
+
insertInto<T extends keyof DB & string>(table: T): InsertQueryBuilder<DB, T, InsertResult>;
|
|
164
164
|
/**
|
|
165
165
|
* Creates a delete query.
|
|
166
166
|
*
|
|
167
|
-
* See the {@link
|
|
167
|
+
* See the {@link WhereInterface.where} method for examples on how to specify
|
|
168
168
|
* a where clause for the delete operation.
|
|
169
169
|
*
|
|
170
170
|
* The return value of the query is an instance of {@link DeleteResult}.
|
|
171
171
|
*
|
|
172
|
-
*
|
|
172
|
+
* ### Examples
|
|
173
|
+
*
|
|
173
174
|
* ```ts
|
|
174
175
|
* const result = await db
|
|
175
176
|
* .deleteFrom('person')
|
|
@@ -179,19 +180,20 @@ export declare class QueryCreator<DB> {
|
|
|
179
180
|
* console.log(result.numDeletedRows)
|
|
180
181
|
* ```
|
|
181
182
|
*/
|
|
182
|
-
deleteFrom<TR extends TableReference<DB>>(table: TR):
|
|
183
|
+
deleteFrom<TR extends TableReference<DB>>(table: TR): DeleteQueryBuilder<TableExpressionDatabase<DB, TR>, TableExpressionTables<DB, never, TR>, DeleteResult>;
|
|
183
184
|
/**
|
|
184
185
|
* Creates an update query.
|
|
185
186
|
*
|
|
186
|
-
* See the {@link
|
|
187
|
+
* See the {@link WhereInterface.where} method for examples on how to specify
|
|
187
188
|
* a where clause for the update operation.
|
|
188
189
|
*
|
|
189
|
-
* See the {@link
|
|
190
|
+
* See the {@link UpdateQueryBuilder.set} method for examples on how to
|
|
190
191
|
* specify the updates.
|
|
191
192
|
*
|
|
192
193
|
* The return value of the query is an {@link UpdateResult}.
|
|
193
194
|
*
|
|
194
|
-
*
|
|
195
|
+
* ### Examples
|
|
196
|
+
*
|
|
195
197
|
* ```ts
|
|
196
198
|
* const result = await db
|
|
197
199
|
* .updateTable('person')
|
|
@@ -202,11 +204,12 @@ export declare class QueryCreator<DB> {
|
|
|
202
204
|
* console.log(result.numUpdatedRows)
|
|
203
205
|
* ```
|
|
204
206
|
*/
|
|
205
|
-
updateTable<TR extends TableReference<DB>>(table: TR):
|
|
207
|
+
updateTable<TR extends TableReference<DB>>(table: TR): UpdateQueryBuilder<TableExpressionDatabase<DB, TR>, TableExpressionTables<DB, never, TR>, UpdateResult>;
|
|
206
208
|
/**
|
|
207
209
|
* Creates a `with` query (common table expressions).
|
|
208
210
|
*
|
|
209
|
-
*
|
|
211
|
+
* ### Examples
|
|
212
|
+
*
|
|
210
213
|
* ```ts
|
|
211
214
|
* await db
|
|
212
215
|
* .with('jennifers', (db) => db
|
|
@@ -233,7 +236,8 @@ export declare class QueryCreator<DB> {
|
|
|
233
236
|
* This only affects the query created through the builder returned from
|
|
234
237
|
* this method and doesn't modify the `db` instance.
|
|
235
238
|
*
|
|
236
|
-
*
|
|
239
|
+
* ### Examples
|
|
240
|
+
*
|
|
237
241
|
* ```
|
|
238
242
|
* await db.withSchema('mammals')
|
|
239
243
|
* .selectFrom('pet')
|
|
@@ -250,7 +254,6 @@ export declare class QueryCreator<DB> {
|
|
|
250
254
|
* on "public"."person"."id" = "mammals"."pet"."owner_id"
|
|
251
255
|
* ```
|
|
252
256
|
*
|
|
253
|
-
* @example
|
|
254
257
|
* `withSchema` is smart enough to not add schema for aliases,
|
|
255
258
|
* common table expressions or other places where the schema
|
|
256
259
|
* doesn't belong to:
|
|
@@ -288,14 +291,8 @@ export declare class QueryCreator<DB> {
|
|
|
288
291
|
* Raw builder instances can be passed to pretty much anywhere: `select`, `where`,
|
|
289
292
|
* `*Join`, `groupBy`, `orderBy` etc. Just try it. If the method accepts it, it works.
|
|
290
293
|
*
|
|
291
|
-
*
|
|
292
|
-
* placeholders. `?` for values and `??` for identifiers such as column names
|
|
293
|
-
* or `column.table` references.
|
|
294
|
+
* ### Examples
|
|
294
295
|
*
|
|
295
|
-
* @param params - The parameters that will be bound to the `?` and `??` placeholders in
|
|
296
|
-
* the sql string.
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
296
|
* Example of using `raw` in a select statement:
|
|
300
297
|
*
|
|
301
298
|
* ```ts
|
|
@@ -349,7 +346,6 @@ export declare class QueryCreator<DB> {
|
|
|
349
346
|
* array, never to the SQL string directly. But if the column names or values are trusted
|
|
350
347
|
* and known at compile time, there is no reason to use parameters.
|
|
351
348
|
*
|
|
352
|
-
* @example
|
|
353
349
|
* Example of using `raw` in `where`:
|
|
354
350
|
*
|
|
355
351
|
* ```ts
|
|
@@ -375,7 +371,6 @@ export declare class QueryCreator<DB> {
|
|
|
375
371
|
* years. The number of years in this example is an untrusted user input, and therefore we use
|
|
376
372
|
* a `?` placeholder for it.
|
|
377
373
|
*
|
|
378
|
-
* @example
|
|
379
374
|
* Example of creating a completely raw query from scratch:
|
|
380
375
|
*
|
|
381
376
|
* ```ts
|
|
@@ -387,6 +382,13 @@ export declare class QueryCreator<DB> {
|
|
|
387
382
|
* this case we know the resulting items will be of type `Person` se specify that.
|
|
388
383
|
* The result of `execute()` method is always an array. In this case the type of
|
|
389
384
|
* the `persons` variable is `Person[]`.
|
|
385
|
+
*
|
|
386
|
+
* @param sql - The raw SQL. Special strings `?` and `??` can be used as parameter
|
|
387
|
+
* placeholders. `?` for values and `??` for identifiers such as column names
|
|
388
|
+
* or `column.table` references.
|
|
389
|
+
*
|
|
390
|
+
* @param params - The parameters that will be bound to the `?` and `??` placeholders in
|
|
391
|
+
* the sql string.
|
|
390
392
|
*/
|
|
391
393
|
raw<T = unknown>(sql: string, parameters?: any[]): RawBuilder<T>;
|
|
392
394
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueryCreator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const select_query_builder_js_1 = require("./query-builder/select-query-builder.js");
|
|
5
|
+
const insert_query_builder_js_1 = require("./query-builder/insert-query-builder.js");
|
|
6
|
+
const delete_query_builder_js_1 = require("./query-builder/delete-query-builder.js");
|
|
7
|
+
const update_query_builder_js_1 = require("./query-builder/update-query-builder.js");
|
|
5
8
|
const delete_query_node_js_1 = require("./operation-node/delete-query-node.js");
|
|
6
9
|
const insert_query_node_js_1 = require("./operation-node/insert-query-node.js");
|
|
7
10
|
const select_query_node_js_1 = require("./operation-node/select-query-node.js");
|
|
@@ -19,7 +22,7 @@ class QueryCreator {
|
|
|
19
22
|
this.#props = (0, object_utils_js_1.freeze)(props);
|
|
20
23
|
}
|
|
21
24
|
selectFrom(from) {
|
|
22
|
-
return new
|
|
25
|
+
return new select_query_builder_js_1.SelectQueryBuilder({
|
|
23
26
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
24
27
|
executor: this.#props.executor,
|
|
25
28
|
parseContext: this.#props.parseContext,
|
|
@@ -30,14 +33,15 @@ class QueryCreator {
|
|
|
30
33
|
* Creates an insert query.
|
|
31
34
|
*
|
|
32
35
|
* The return value of this query is an instance of {@link InsertResult}. {@link InsertResult}
|
|
33
|
-
* has the {@link InsertResult.insertId |
|
|
36
|
+
* has the {@link InsertResult.insertId | insertId} field that holds the auto incremented id of
|
|
34
37
|
* the inserted row if the db returned one.
|
|
35
38
|
*
|
|
36
|
-
* See the {@link
|
|
37
|
-
* the {@link
|
|
39
|
+
* See the {@link InsertQueryBuilder.values | values} method for more info and examples. Also see
|
|
40
|
+
* the {@link ReturningInterface.returning | returning} method for a way to return columns
|
|
38
41
|
* on supported databases like PostgreSQL.
|
|
39
42
|
*
|
|
40
|
-
*
|
|
43
|
+
* ### Examples
|
|
44
|
+
*
|
|
41
45
|
* ```ts
|
|
42
46
|
* const result = await db
|
|
43
47
|
* .insertInto('person')
|
|
@@ -51,11 +55,10 @@ class QueryCreator {
|
|
|
51
55
|
* console.log(result.insertId)
|
|
52
56
|
* ```
|
|
53
57
|
*
|
|
54
|
-
* @example
|
|
55
58
|
* Some databases like PostgreSQL support the `returning` method:
|
|
56
59
|
*
|
|
57
60
|
* ```ts
|
|
58
|
-
* const {
|
|
61
|
+
* const { id } = await db
|
|
59
62
|
* .insertInto('person')
|
|
60
63
|
* .values({
|
|
61
64
|
* id: db.generated,
|
|
@@ -67,7 +70,7 @@ class QueryCreator {
|
|
|
67
70
|
* ```
|
|
68
71
|
*/
|
|
69
72
|
insertInto(table) {
|
|
70
|
-
return new
|
|
73
|
+
return new insert_query_builder_js_1.InsertQueryBuilder({
|
|
71
74
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
72
75
|
executor: this.#props.executor,
|
|
73
76
|
parseContext: this.#props.parseContext,
|
|
@@ -77,12 +80,13 @@ class QueryCreator {
|
|
|
77
80
|
/**
|
|
78
81
|
* Creates a delete query.
|
|
79
82
|
*
|
|
80
|
-
* See the {@link
|
|
83
|
+
* See the {@link WhereInterface.where} method for examples on how to specify
|
|
81
84
|
* a where clause for the delete operation.
|
|
82
85
|
*
|
|
83
86
|
* The return value of the query is an instance of {@link DeleteResult}.
|
|
84
87
|
*
|
|
85
|
-
*
|
|
88
|
+
* ### Examples
|
|
89
|
+
*
|
|
86
90
|
* ```ts
|
|
87
91
|
* const result = await db
|
|
88
92
|
* .deleteFrom('person')
|
|
@@ -93,7 +97,7 @@ class QueryCreator {
|
|
|
93
97
|
* ```
|
|
94
98
|
*/
|
|
95
99
|
deleteFrom(table) {
|
|
96
|
-
return new
|
|
100
|
+
return new delete_query_builder_js_1.DeleteQueryBuilder({
|
|
97
101
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
98
102
|
executor: this.#props.executor,
|
|
99
103
|
parseContext: this.#props.parseContext,
|
|
@@ -103,15 +107,16 @@ class QueryCreator {
|
|
|
103
107
|
/**
|
|
104
108
|
* Creates an update query.
|
|
105
109
|
*
|
|
106
|
-
* See the {@link
|
|
110
|
+
* See the {@link WhereInterface.where} method for examples on how to specify
|
|
107
111
|
* a where clause for the update operation.
|
|
108
112
|
*
|
|
109
|
-
* See the {@link
|
|
113
|
+
* See the {@link UpdateQueryBuilder.set} method for examples on how to
|
|
110
114
|
* specify the updates.
|
|
111
115
|
*
|
|
112
116
|
* The return value of the query is an {@link UpdateResult}.
|
|
113
117
|
*
|
|
114
|
-
*
|
|
118
|
+
* ### Examples
|
|
119
|
+
*
|
|
115
120
|
* ```ts
|
|
116
121
|
* const result = await db
|
|
117
122
|
* .updateTable('person')
|
|
@@ -123,7 +128,7 @@ class QueryCreator {
|
|
|
123
128
|
* ```
|
|
124
129
|
*/
|
|
125
130
|
updateTable(table) {
|
|
126
|
-
return new
|
|
131
|
+
return new update_query_builder_js_1.UpdateQueryBuilder({
|
|
127
132
|
queryId: (0, query_id_js_1.createQueryId)(),
|
|
128
133
|
executor: this.#props.executor,
|
|
129
134
|
parseContext: this.#props.parseContext,
|
|
@@ -133,7 +138,8 @@ class QueryCreator {
|
|
|
133
138
|
/**
|
|
134
139
|
* Creates a `with` query (common table expressions).
|
|
135
140
|
*
|
|
136
|
-
*
|
|
141
|
+
* ### Examples
|
|
142
|
+
*
|
|
137
143
|
* ```ts
|
|
138
144
|
* await db
|
|
139
145
|
* .with('jennifers', (db) => db
|
|
@@ -168,7 +174,8 @@ class QueryCreator {
|
|
|
168
174
|
* This only affects the query created through the builder returned from
|
|
169
175
|
* this method and doesn't modify the `db` instance.
|
|
170
176
|
*
|
|
171
|
-
*
|
|
177
|
+
* ### Examples
|
|
178
|
+
*
|
|
172
179
|
* ```
|
|
173
180
|
* await db.withSchema('mammals')
|
|
174
181
|
* .selectFrom('pet')
|
|
@@ -185,7 +192,6 @@ class QueryCreator {
|
|
|
185
192
|
* on "public"."person"."id" = "mammals"."pet"."owner_id"
|
|
186
193
|
* ```
|
|
187
194
|
*
|
|
188
|
-
* @example
|
|
189
195
|
* `withSchema` is smart enough to not add schema for aliases,
|
|
190
196
|
* common table expressions or other places where the schema
|
|
191
197
|
* doesn't belong to:
|
|
@@ -228,14 +234,8 @@ class QueryCreator {
|
|
|
228
234
|
* Raw builder instances can be passed to pretty much anywhere: `select`, `where`,
|
|
229
235
|
* `*Join`, `groupBy`, `orderBy` etc. Just try it. If the method accepts it, it works.
|
|
230
236
|
*
|
|
231
|
-
*
|
|
232
|
-
* placeholders. `?` for values and `??` for identifiers such as column names
|
|
233
|
-
* or `column.table` references.
|
|
234
|
-
*
|
|
235
|
-
* @param params - The parameters that will be bound to the `?` and `??` placeholders in
|
|
236
|
-
* the sql string.
|
|
237
|
+
* ### Examples
|
|
237
238
|
*
|
|
238
|
-
* @example
|
|
239
239
|
* Example of using `raw` in a select statement:
|
|
240
240
|
*
|
|
241
241
|
* ```ts
|
|
@@ -289,7 +289,6 @@ class QueryCreator {
|
|
|
289
289
|
* array, never to the SQL string directly. But if the column names or values are trusted
|
|
290
290
|
* and known at compile time, there is no reason to use parameters.
|
|
291
291
|
*
|
|
292
|
-
* @example
|
|
293
292
|
* Example of using `raw` in `where`:
|
|
294
293
|
*
|
|
295
294
|
* ```ts
|
|
@@ -315,7 +314,6 @@ class QueryCreator {
|
|
|
315
314
|
* years. The number of years in this example is an untrusted user input, and therefore we use
|
|
316
315
|
* a `?` placeholder for it.
|
|
317
316
|
*
|
|
318
|
-
* @example
|
|
319
317
|
* Example of creating a completely raw query from scratch:
|
|
320
318
|
*
|
|
321
319
|
* ```ts
|
|
@@ -327,6 +325,13 @@ class QueryCreator {
|
|
|
327
325
|
* this case we know the resulting items will be of type `Person` se specify that.
|
|
328
326
|
* The result of `execute()` method is always an array. In this case the type of
|
|
329
327
|
* the `persons` variable is `Person[]`.
|
|
328
|
+
*
|
|
329
|
+
* @param sql - The raw SQL. Special strings `?` and `??` can be used as parameter
|
|
330
|
+
* placeholders. `?` for values and `??` for identifiers such as column names
|
|
331
|
+
* or `column.table` references.
|
|
332
|
+
*
|
|
333
|
+
* @param params - The parameters that will be bound to the `?` and `??` placeholders in
|
|
334
|
+
* the sql string.
|
|
330
335
|
*/
|
|
331
336
|
raw(sql, parameters) {
|
|
332
337
|
return new raw_builder_js_1.RawBuilder({
|
|
@@ -6,7 +6,7 @@ import { KyselyPlugin } from '../plugin/kysely-plugin.js';
|
|
|
6
6
|
import { QueryId } from '../util/query-id.js';
|
|
7
7
|
/**
|
|
8
8
|
* This class abstracts away the details of how to compile a query into SQL
|
|
9
|
-
* and execute it. Instead of passing around all those details, {@link
|
|
9
|
+
* and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
|
|
10
10
|
* and other classes that execute queries can just pass around and instance of
|
|
11
11
|
* `QueryExecutor`.
|
|
12
12
|
*/
|
|
@@ -4,7 +4,7 @@ exports.QueryExecutor = void 0;
|
|
|
4
4
|
const object_utils_js_1 = require("../util/object-utils.js");
|
|
5
5
|
/**
|
|
6
6
|
* This class abstracts away the details of how to compile a query into SQL
|
|
7
|
-
* and execute it. Instead of passing around all those details, {@link
|
|
7
|
+
* and execute it. Instead of passing around all those details, {@link SelectQueryBuilder}
|
|
8
8
|
* and other classes that execute queries can just pass around and instance of
|
|
9
9
|
* `QueryExecutor`.
|
|
10
10
|
*/
|
|
@@ -5,6 +5,7 @@ import { RawNode } from '../operation-node/raw-node.js';
|
|
|
5
5
|
import { CompiledQuery } from '../query-compiler/compiled-query.js';
|
|
6
6
|
import { QueryExecutor } from '../query-executor/query-executor.js';
|
|
7
7
|
import { QueryId } from '../util/query-id.js';
|
|
8
|
+
import { KyselyPlugin } from '../plugin/kysely-plugin.js';
|
|
8
9
|
export declare class RawBuilder<O = unknown> implements OperationNodeSource {
|
|
9
10
|
#private;
|
|
10
11
|
constructor(props: RawBuilderProps);
|
|
@@ -16,6 +17,7 @@ export declare class RawBuilder<O = unknown> implements OperationNodeSource {
|
|
|
16
17
|
* of this `RawBuilder` with a new output type.
|
|
17
18
|
*/
|
|
18
19
|
castTo<T>(): RawBuilder<T>;
|
|
20
|
+
withPlugin(plugin: KyselyPlugin): RawBuilder<O>;
|
|
19
21
|
toOperationNode(): RawNode;
|
|
20
22
|
compile(): CompiledQuery;
|
|
21
23
|
execute(): Promise<QueryResult<O>>;
|
|
@@ -27,6 +27,12 @@ class RawBuilder {
|
|
|
27
27
|
...this.#props,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
withPlugin(plugin) {
|
|
31
|
+
return new RawBuilder({
|
|
32
|
+
...this.#props,
|
|
33
|
+
executor: this.#props.executor.withPlugin(plugin),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
30
36
|
toOperationNode() {
|
|
31
37
|
const parameterPlaceholderRegex = /(\?\??)/g;
|
|
32
38
|
const sql = this.#props.sql;
|
|
@@ -60,7 +60,7 @@ export declare class AlterTableExecutor implements OperationNodeSource, Compilab
|
|
|
60
60
|
}
|
|
61
61
|
export interface AlterTableExecutorProps extends AlterTableBuilderProps {
|
|
62
62
|
}
|
|
63
|
-
export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface
|
|
63
|
+
export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource, Compilable {
|
|
64
64
|
#private;
|
|
65
65
|
constructor(props: AlterTableAddColumnBuilderProps);
|
|
66
66
|
autoIncrement(): AlterTableAddColumnBuilder;
|
|
@@ -81,7 +81,7 @@ export declare class AlterTableAddColumnBuilder implements ColumnDefinitionBuild
|
|
|
81
81
|
export interface AlterTableAddColumnBuilderProps extends AlterTableBuilderProps {
|
|
82
82
|
readonly columnBuilder: ColumnDefinitionBuilder;
|
|
83
83
|
}
|
|
84
|
-
export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBuilderInterface
|
|
84
|
+
export declare class AlterTableModifyColumnBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource, Compilable {
|
|
85
85
|
#private;
|
|
86
86
|
constructor(props: AlterTableModifyColumnBuilderProps);
|
|
87
87
|
autoIncrement(): AlterTableModifyColumnBuilder;
|
|
@@ -4,7 +4,7 @@ import { PrimitiveValue } from '../util/object-utils.js';
|
|
|
4
4
|
import { ColumnDefinitionNode } from '../operation-node/column-definition-node.js';
|
|
5
5
|
import { AnyRawBuilder } from '../util/type-utils.js';
|
|
6
6
|
import { DefaultValueExpression } from '../parser/default-value-parser.js';
|
|
7
|
-
export interface ColumnDefinitionBuilderInterface
|
|
7
|
+
export interface ColumnDefinitionBuilderInterface {
|
|
8
8
|
/**
|
|
9
9
|
* Adds `auto_increment` or `autoincrement` to the column definition
|
|
10
10
|
* depending on the dialect.
|
|
@@ -12,14 +12,14 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
12
12
|
* Some dialects like PostgreSQL don't support this. On PostgreSQL
|
|
13
13
|
* you can use the `serial` or `bigserial` data type instead.
|
|
14
14
|
*/
|
|
15
|
-
autoIncrement():
|
|
15
|
+
autoIncrement(): ColumnDefinitionBuilderInterface;
|
|
16
16
|
/**
|
|
17
17
|
* Makes the column the primary key.
|
|
18
18
|
*
|
|
19
19
|
* If you want to specify a composite primary key use the
|
|
20
20
|
* {@link TableBuilder.addPrimaryKeyConstraint} method.
|
|
21
21
|
*/
|
|
22
|
-
primaryKey():
|
|
22
|
+
primaryKey(): ColumnDefinitionBuilderInterface;
|
|
23
23
|
/**
|
|
24
24
|
* Adds a foreign key constraint for the column.
|
|
25
25
|
*
|
|
@@ -27,12 +27,13 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
27
27
|
* column definition (like MySQL 5) you need to call the table level
|
|
28
28
|
* {@link TableBuilder.addForeignKeyConstraint} method instead.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* ### Examples
|
|
31
|
+
*
|
|
31
32
|
* ```ts
|
|
32
33
|
* col.references('person.id')
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
|
-
references(ref: string):
|
|
36
|
+
references(ref: string): ColumnDefinitionBuilderInterface;
|
|
36
37
|
/**
|
|
37
38
|
* Adds an `on delete` constraint for the foreign key column.
|
|
38
39
|
*
|
|
@@ -40,33 +41,36 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
40
41
|
* column definition (like MySQL 5) you need to call the table level
|
|
41
42
|
* {@link TableBuilder.addForeignKeyConstraint} method instead.
|
|
42
43
|
*
|
|
43
|
-
*
|
|
44
|
+
* ### Examples
|
|
45
|
+
*
|
|
44
46
|
* ```ts
|
|
45
47
|
* col.references('person.id').onDelete('cascade')
|
|
46
48
|
* ```
|
|
47
49
|
*/
|
|
48
|
-
onDelete(onDelete: OnModifyForeignAction):
|
|
50
|
+
onDelete(onDelete: OnModifyForeignAction): ColumnDefinitionBuilderInterface;
|
|
49
51
|
/**
|
|
50
52
|
* Adds an `on update` constraint for the foreign key column.
|
|
51
53
|
*
|
|
52
|
-
*
|
|
54
|
+
* ### Examples
|
|
55
|
+
*
|
|
53
56
|
* ```ts
|
|
54
57
|
* col.references('person.id').onUpdate('cascade')
|
|
55
58
|
* ```
|
|
56
59
|
*/
|
|
57
|
-
onUpdate(onUpdate: OnModifyForeignAction):
|
|
60
|
+
onUpdate(onUpdate: OnModifyForeignAction): ColumnDefinitionBuilderInterface;
|
|
58
61
|
/**
|
|
59
62
|
* Adds a unique constraint for the column.
|
|
60
63
|
*/
|
|
61
|
-
unique():
|
|
64
|
+
unique(): ColumnDefinitionBuilderInterface;
|
|
62
65
|
/**
|
|
63
66
|
* Adds a `not null` constraint for the column.
|
|
64
67
|
*/
|
|
65
|
-
notNull():
|
|
68
|
+
notNull(): ColumnDefinitionBuilderInterface;
|
|
66
69
|
/**
|
|
67
70
|
* Adds a default value constraint for the column.
|
|
68
71
|
*
|
|
69
|
-
*
|
|
72
|
+
* ### Examples
|
|
73
|
+
*
|
|
70
74
|
* ```ts
|
|
71
75
|
* db.schema
|
|
72
76
|
* .createTable('pet')
|
|
@@ -74,11 +78,12 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
74
78
|
* .execute()
|
|
75
79
|
* ```
|
|
76
80
|
*/
|
|
77
|
-
defaultTo(value: PrimitiveValue | AnyRawBuilder):
|
|
81
|
+
defaultTo(value: PrimitiveValue | AnyRawBuilder): ColumnDefinitionBuilderInterface;
|
|
78
82
|
/**
|
|
79
83
|
* Adds a check constraint for the column.
|
|
80
84
|
*
|
|
81
|
-
*
|
|
85
|
+
* ### Examples
|
|
86
|
+
*
|
|
82
87
|
* ```ts
|
|
83
88
|
* db.schema
|
|
84
89
|
* .createTable('pet')
|
|
@@ -86,11 +91,12 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
86
91
|
* .execute()
|
|
87
92
|
* ```
|
|
88
93
|
*/
|
|
89
|
-
check(sql: string):
|
|
94
|
+
check(sql: string): ColumnDefinitionBuilderInterface;
|
|
90
95
|
/**
|
|
91
96
|
* Makes the column a generated column using a `generated always as` statement.
|
|
92
97
|
*
|
|
93
|
-
*
|
|
98
|
+
* ### Examples
|
|
99
|
+
*
|
|
94
100
|
* ```ts
|
|
95
101
|
* db.schema
|
|
96
102
|
* .createTable('person')
|
|
@@ -100,12 +106,13 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
100
106
|
* .execute()
|
|
101
107
|
* ```
|
|
102
108
|
*/
|
|
103
|
-
generatedAlwaysAs(sql: string):
|
|
109
|
+
generatedAlwaysAs(sql: string): ColumnDefinitionBuilderInterface;
|
|
104
110
|
/**
|
|
105
111
|
* Makes a generated column stored instead of virtual. This method can only
|
|
106
112
|
* be used with {@link generatedAlwaysAs}
|
|
107
113
|
*
|
|
108
|
-
*
|
|
114
|
+
* ### Examples
|
|
115
|
+
*
|
|
109
116
|
* ```ts
|
|
110
117
|
* db.schema
|
|
111
118
|
* .createTable('person')
|
|
@@ -116,9 +123,9 @@ export interface ColumnDefinitionBuilderInterface<R> {
|
|
|
116
123
|
* .execute()
|
|
117
124
|
* ```
|
|
118
125
|
*/
|
|
119
|
-
stored():
|
|
126
|
+
stored(): ColumnDefinitionBuilderInterface;
|
|
120
127
|
}
|
|
121
|
-
export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface
|
|
128
|
+
export declare class ColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface, OperationNodeSource {
|
|
122
129
|
#private;
|
|
123
130
|
constructor(node: ColumnDefinitionNode);
|
|
124
131
|
autoIncrement(): ColumnDefinitionBuilder;
|
|
@@ -30,7 +30,8 @@ export declare class CreateIndexBuilder implements OperationNodeSource, Compilab
|
|
|
30
30
|
/**
|
|
31
31
|
* Specifies an arbitrary expression for the index.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* ### Examples
|
|
34
|
+
*
|
|
34
35
|
* ```ts
|
|
35
36
|
* await db.schema
|
|
36
37
|
* .createIndex('person_first_name_index')
|