kysely 0.11.4 → 0.13.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 +35 -11
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +36 -0
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +38 -2
- package/dist/cjs/dialect/mysql/mysql-adapter.js +2 -1
- package/dist/cjs/dialect/mysql/mysql-dialect.d.ts +16 -0
- package/dist/cjs/dialect/mysql/mysql-driver.d.ts +29 -0
- package/dist/cjs/dialect/mysql/mysql-introspector.d.ts +3 -0
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +38 -2
- package/dist/cjs/dialect/postgres/postgres-adapter.js +2 -1
- package/dist/cjs/dialect/postgres/postgres-dialect.d.ts +16 -0
- package/dist/cjs/dialect/postgres/postgres-driver.d.ts +29 -0
- package/dist/cjs/dialect/postgres/postgres-introspector.d.ts +3 -0
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +38 -2
- package/dist/cjs/dialect/sqlite/sqlite-dialect.d.ts +16 -0
- package/dist/cjs/dialect/sqlite/sqlite-driver.d.ts +29 -0
- package/dist/cjs/dialect/sqlite/sqlite-introspector.d.ts +3 -0
- package/dist/cjs/driver/default-connection-provider.d.ts +4 -0
- package/dist/cjs/driver/runtime-driver.d.ts +29 -0
- package/dist/cjs/driver/single-connection-provider.d.ts +4 -0
- 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 +15 -4
- package/dist/cjs/index.js +12 -1
- package/dist/cjs/kysely.d.ts +170 -11
- package/dist/cjs/kysely.js +69 -9
- package/dist/cjs/migration/migration.d.ts +156 -13
- package/dist/cjs/migration/migration.js +256 -135
- package/dist/cjs/operation-node/column-definition-node.d.ts +6 -5
- package/dist/cjs/operation-node/column-definition-node.js +0 -4
- package/dist/cjs/operation-node/common-table-expression-name-node.d.ts +15 -0
- package/dist/cjs/operation-node/common-table-expression-name-node.js +23 -0
- package/dist/cjs/operation-node/common-table-expression-node.d.ts +3 -3
- 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 +4 -0
- package/dist/cjs/operation-node/operation-node-transformer.js +22 -2
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +4 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +2 -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/operation-node/with-node.d.ts +3 -1
- package/dist/cjs/operation-node/with-node.js +2 -1
- package/dist/cjs/package.json +1 -3
- 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 -4
- package/dist/cjs/parser/filter-parser.js +21 -24
- package/dist/cjs/parser/insert-values-parser.d.ts +5 -9
- package/dist/cjs/parser/insert-values-parser.js +27 -41
- package/dist/cjs/parser/order-by-parser.d.ts +1 -1
- package/dist/cjs/parser/parse-context.d.ts +22 -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 +36 -6
- package/dist/cjs/parser/with-parser.js +13 -2
- package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +36 -2
- package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.d.ts +34 -0
- package/dist/cjs/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +34 -0
- package/dist/cjs/plugin/with-schema/with-schema-transformer.js +8 -0
- package/dist/cjs/query-builder/delete-query-builder.d.ts +647 -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 +504 -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 +19 -20
- package/dist/cjs/query-builder/join-builder.js +12 -12
- package/dist/cjs/query-builder/join-interface.d.ts +130 -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/{query-builder.d.ts → select-query-builder.d.ts} +145 -651
- package/dist/cjs/query-builder/select-query-builder.js +571 -0
- package/dist/cjs/query-builder/update-query-builder.d.ts +735 -0
- package/dist/cjs/query-builder/update-query-builder.js +279 -0
- package/dist/cjs/query-builder/where-interface.d.ts +378 -0
- package/dist/cjs/query-builder/where-interface.js +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +4 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +37 -6
- package/dist/cjs/query-creator.d.ts +69 -43
- package/dist/cjs/query-creator.js +66 -29
- package/dist/cjs/query-executor/default-query-executor.d.ts +19 -0
- package/dist/cjs/query-executor/noop-query-executor.d.ts +19 -0
- 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 +7 -1
- package/dist/cjs/schema/alter-table-builder.d.ts +230 -2
- package/dist/cjs/schema/alter-table-builder.js +12 -0
- package/dist/cjs/schema/column-definition-builder.d.ts +147 -20
- package/dist/cjs/schema/column-definition-builder.js +4 -1
- 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/log.d.ts +3 -2
- package/dist/cjs/util/log.js +8 -15
- package/dist/cjs/util/type-utils.d.ts +7 -7
- package/dist/esm/dialect/dialect-adapter-base.d.ts +36 -0
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +38 -2
- package/dist/esm/dialect/mysql/mysql-adapter.js +2 -1
- package/dist/esm/dialect/mysql/mysql-dialect.d.ts +16 -0
- package/dist/esm/dialect/mysql/mysql-driver.d.ts +29 -0
- package/dist/esm/dialect/mysql/mysql-introspector.d.ts +3 -0
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +38 -2
- package/dist/esm/dialect/postgres/postgres-adapter.js +2 -1
- package/dist/esm/dialect/postgres/postgres-dialect.d.ts +16 -0
- package/dist/esm/dialect/postgres/postgres-driver.d.ts +29 -0
- package/dist/esm/dialect/postgres/postgres-introspector.d.ts +3 -0
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +38 -2
- package/dist/esm/dialect/sqlite/sqlite-dialect.d.ts +16 -0
- package/dist/esm/dialect/sqlite/sqlite-driver.d.ts +29 -0
- package/dist/esm/dialect/sqlite/sqlite-introspector.d.ts +3 -0
- package/dist/esm/driver/default-connection-provider.d.ts +4 -0
- package/dist/esm/driver/runtime-driver.d.ts +29 -0
- package/dist/esm/driver/single-connection-provider.d.ts +4 -0
- 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 +15 -4
- package/dist/esm/index.js +12 -1
- package/dist/esm/kysely.d.ts +170 -11
- package/dist/esm/kysely.js +69 -9
- package/dist/esm/migration/migration.d.ts +156 -13
- package/dist/esm/migration/migration.js +255 -134
- package/dist/esm/operation-node/column-definition-node.d.ts +6 -5
- package/dist/esm/operation-node/column-definition-node.js +0 -4
- package/dist/esm/operation-node/common-table-expression-name-node.d.ts +15 -0
- package/dist/esm/operation-node/common-table-expression-name-node.js +20 -0
- package/dist/esm/operation-node/common-table-expression-node.d.ts +3 -3
- 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 +4 -0
- package/dist/esm/operation-node/operation-node-transformer.js +22 -2
- package/dist/esm/operation-node/operation-node-visitor.d.ts +4 -0
- package/dist/esm/operation-node/operation-node-visitor.js +2 -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/operation-node/with-node.d.ts +3 -1
- package/dist/esm/operation-node/with-node.js +2 -1
- package/dist/esm/package.json +1 -3
- 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 -4
- package/dist/esm/parser/filter-parser.js +21 -24
- package/dist/esm/parser/insert-values-parser.d.ts +5 -9
- package/dist/esm/parser/insert-values-parser.js +27 -40
- package/dist/esm/parser/order-by-parser.d.ts +1 -1
- package/dist/esm/parser/parse-context.d.ts +22 -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 +36 -6
- package/dist/esm/parser/with-parser.js +13 -2
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +36 -2
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.d.ts +34 -0
- package/dist/esm/plugin/immediate-value.ts/immediate-value-plugin.js +2 -2
- package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +34 -0
- package/dist/esm/plugin/with-schema/with-schema-transformer.js +8 -0
- package/dist/esm/query-builder/delete-query-builder.d.ts +647 -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 +504 -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 +19 -20
- package/dist/esm/query-builder/join-builder.js +12 -12
- package/dist/esm/query-builder/join-interface.d.ts +130 -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/{query-builder.d.ts → select-query-builder.d.ts} +145 -651
- package/dist/esm/query-builder/select-query-builder.js +566 -0
- package/dist/esm/query-builder/update-query-builder.d.ts +735 -0
- package/dist/esm/query-builder/update-query-builder.js +275 -0
- package/dist/esm/query-builder/where-interface.d.ts +378 -0
- package/dist/esm/query-builder/where-interface.js +1 -0
- package/dist/esm/query-compiler/default-query-compiler.d.ts +4 -0
- package/dist/esm/query-compiler/default-query-compiler.js +37 -6
- package/dist/esm/query-creator.d.ts +69 -43
- package/dist/esm/query-creator.js +66 -29
- package/dist/esm/query-executor/default-query-executor.d.ts +19 -0
- package/dist/esm/query-executor/noop-query-executor.d.ts +19 -0
- 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 +7 -1
- package/dist/esm/schema/alter-table-builder.d.ts +230 -2
- package/dist/esm/schema/alter-table-builder.js +12 -0
- package/dist/esm/schema/column-definition-builder.d.ts +147 -20
- package/dist/esm/schema/column-definition-builder.js +4 -1
- 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/log.d.ts +3 -2
- package/dist/esm/util/log.js +7 -14
- package/dist/esm/util/type-utils.d.ts +7 -7
- package/package.json +10 -8
- package/dist/cjs/query-builder/query-builder.js +0 -1067
- package/dist/esm/query-builder/query-builder.js +0 -1061
package/dist/esm/kysely.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ import { LogConfig } from './util/log.js';
|
|
|
17
17
|
* You should create one instance of `Kysely` per database using the {@link Kysely}
|
|
18
18
|
* constructor. Each `Kysely` instance maintains it's own connection pool.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* ### Examples
|
|
21
|
+
*
|
|
21
22
|
* This example assumes your database has tables `person` and `pet`:
|
|
22
23
|
*
|
|
23
24
|
* ```ts
|
|
@@ -31,7 +32,7 @@ import { LogConfig } from './util/log.js';
|
|
|
31
32
|
* id: number
|
|
32
33
|
* owner_id: number
|
|
33
34
|
* name: string
|
|
34
|
-
* species 'cat' |
|
|
35
|
+
* species 'cat' | 'dog'
|
|
35
36
|
* }
|
|
36
37
|
*
|
|
37
38
|
* interface Database {
|
|
@@ -78,10 +79,11 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
78
79
|
* A value to be used in place of columns that are generated in the database
|
|
79
80
|
* when inserting rows.
|
|
80
81
|
*
|
|
81
|
-
*
|
|
82
|
+
* ### Examples
|
|
83
|
+
*
|
|
82
84
|
* In this example the `Person` table has non-null properties `id` and `created_at`
|
|
83
85
|
* which are both automatically genereted by the database. Since their types are
|
|
84
|
-
* `number` and `string` respectively instead of `number |
|
|
86
|
+
* `number` and `string` respectively instead of `number | null` and `string | null`
|
|
85
87
|
* the `values` method requires you to give a value for them. the `generated`
|
|
86
88
|
* placeholder can be used in these cases.
|
|
87
89
|
*
|
|
@@ -136,12 +138,13 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
136
138
|
* transaction. If the function throws, the transaction is rolled back. Otherwise
|
|
137
139
|
* the transaction is committed.
|
|
138
140
|
*
|
|
139
|
-
* The callback function passed to the {@link TransactionBuilder.execute |
|
|
141
|
+
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
140
142
|
* method gets the transaction object as its only argument. The transaction is
|
|
141
143
|
* of type {@link Transaction} which inherits {@link Kysely}. Any query
|
|
142
144
|
* started through the transaction object is executed inside the transaction.
|
|
143
145
|
*
|
|
144
|
-
*
|
|
146
|
+
* ### Examples
|
|
147
|
+
*
|
|
145
148
|
* ```ts
|
|
146
149
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
147
150
|
* const jennifer = await trx.insertInto('person')
|
|
@@ -167,8 +170,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
167
170
|
* })
|
|
168
171
|
* ```
|
|
169
172
|
*
|
|
170
|
-
*
|
|
171
|
-
* Setting the isolation level.
|
|
173
|
+
* Setting the isolation level:
|
|
172
174
|
*
|
|
173
175
|
* ```ts
|
|
174
176
|
* await db
|
|
@@ -183,7 +185,8 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
183
185
|
/**
|
|
184
186
|
* Provides a kysely instance bound to a single database connection.
|
|
185
187
|
*
|
|
186
|
-
*
|
|
188
|
+
* ### Examples
|
|
189
|
+
*
|
|
187
190
|
* ```ts
|
|
188
191
|
* await db
|
|
189
192
|
* .connection()
|
|
@@ -204,6 +207,38 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
204
207
|
* Returns a copy of this Kysely instance without any plugins.
|
|
205
208
|
*/
|
|
206
209
|
withoutPlugins(): Kysely<DB>;
|
|
210
|
+
/**
|
|
211
|
+
* Returns a copy of this Kysely instance with tables added to its
|
|
212
|
+
* database type.
|
|
213
|
+
*
|
|
214
|
+
* This method only modifies the types and doesn't affect any of the
|
|
215
|
+
* executed queries in any way.
|
|
216
|
+
*
|
|
217
|
+
* ### Examples
|
|
218
|
+
*
|
|
219
|
+
* The following example adds and uses a temporary table:
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* await db.schema
|
|
224
|
+
* .createTable('temp_table')
|
|
225
|
+
* .temporary()
|
|
226
|
+
* .addColumn('some_column', 'integer')
|
|
227
|
+
* .execute()
|
|
228
|
+
*
|
|
229
|
+
* const tempDb = db.withTables<{
|
|
230
|
+
* temp_table: {
|
|
231
|
+
* some_column: number
|
|
232
|
+
* }
|
|
233
|
+
* }>()
|
|
234
|
+
*
|
|
235
|
+
* await tempDb
|
|
236
|
+
* .insertInto('temp_table')
|
|
237
|
+
* .values({ some_column: 100 })
|
|
238
|
+
* .execute()
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
withTables<T extends Record<string, Record<string, any>>>(): Kysely<DB & T>;
|
|
207
242
|
/**
|
|
208
243
|
* Releases all resources and disconnects from the database.
|
|
209
244
|
*
|
|
@@ -218,10 +253,134 @@ export declare class Kysely<DB> extends QueryCreator<DB> {
|
|
|
218
253
|
get isTransaction(): boolean;
|
|
219
254
|
}
|
|
220
255
|
export declare class Transaction<DB> extends Kysely<DB> {
|
|
256
|
+
#private;
|
|
257
|
+
constructor(props: KyselyProps);
|
|
258
|
+
/**
|
|
259
|
+
* Returns true if this `Kysely` instance is a transaction.
|
|
260
|
+
*
|
|
261
|
+
* You can also use `db instanceof Transaction`.
|
|
262
|
+
*/
|
|
221
263
|
get isTransaction(): true;
|
|
264
|
+
/**
|
|
265
|
+
* Returns the {@link MigrationModule} module for managing and running migrations.
|
|
266
|
+
*/
|
|
222
267
|
get migration(): MigrationModule;
|
|
268
|
+
/**
|
|
269
|
+
* Creates a {@link TransactionBuilder} that can be used to run queries inside a transaction.
|
|
270
|
+
*
|
|
271
|
+
* The returned {@link TransactionBuilder} can be used to configure the transaction. The
|
|
272
|
+
* {@link TransactionBuilder.execute} method can then be called to run the transaction.
|
|
273
|
+
* {@link TransactionBuilder.execute} takes a function that is run inside the
|
|
274
|
+
* transaction. If the function throws, the transaction is rolled back. Otherwise
|
|
275
|
+
* the transaction is committed.
|
|
276
|
+
*
|
|
277
|
+
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
278
|
+
* method gets the transaction object as its only argument. The transaction is
|
|
279
|
+
* of type {@link Transaction} which inherits {@link Kysely}. Any query
|
|
280
|
+
* started through the transaction object is executed inside the transaction.
|
|
281
|
+
*
|
|
282
|
+
* ### Examples
|
|
283
|
+
*
|
|
284
|
+
* ```ts
|
|
285
|
+
* const catto = await db.transaction().execute(async (trx) => {
|
|
286
|
+
* const jennifer = await trx.insertInto('person')
|
|
287
|
+
* .values({
|
|
288
|
+
* id: db.generated,
|
|
289
|
+
* first_name: 'Jennifer',
|
|
290
|
+
* last_name: 'Aniston',
|
|
291
|
+
* })
|
|
292
|
+
* .returning('id')
|
|
293
|
+
* .executeTakeFirstOrThrow()
|
|
294
|
+
*
|
|
295
|
+
* await someFunction(trx, jennifer)
|
|
296
|
+
*
|
|
297
|
+
* return await trx.insertInto('pet')
|
|
298
|
+
* .values({
|
|
299
|
+
* id: db.generated,
|
|
300
|
+
* user_id: jennifer.id,
|
|
301
|
+
* name: 'Catto',
|
|
302
|
+
* species: 'cat'
|
|
303
|
+
* })
|
|
304
|
+
* .returning('*')
|
|
305
|
+
* .executeTakeFirst()
|
|
306
|
+
* })
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* Setting the isolation level:
|
|
310
|
+
*
|
|
311
|
+
* ```ts
|
|
312
|
+
* await db
|
|
313
|
+
* .transaction()
|
|
314
|
+
* .setIsolationLevel('serializable')
|
|
315
|
+
* .execute(async (trx) => {
|
|
316
|
+
* await doStuff(trx)
|
|
317
|
+
* })
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
223
320
|
transaction(): TransactionBuilder<DB>;
|
|
321
|
+
/**
|
|
322
|
+
* Provides a kysely instance bound to a single database connection.
|
|
323
|
+
*
|
|
324
|
+
* ### Examples
|
|
325
|
+
*
|
|
326
|
+
* ```ts
|
|
327
|
+
* await db
|
|
328
|
+
* .connection()
|
|
329
|
+
* .execute(async (db) => {
|
|
330
|
+
* // `db` is an instance of `Kysely` that's bound to a single
|
|
331
|
+
* // database connection. All queries executed through `db` use
|
|
332
|
+
* // the same connection.
|
|
333
|
+
* await doStuff(db)
|
|
334
|
+
* })
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
connection(): ConnectionBuilder<DB>;
|
|
338
|
+
/**
|
|
339
|
+
* Releases all resources and disconnects from the database.
|
|
340
|
+
*
|
|
341
|
+
* You need to call this when you are done using the `Kysely` instance.
|
|
342
|
+
*/
|
|
224
343
|
destroy(): Promise<void>;
|
|
344
|
+
/**
|
|
345
|
+
* Returns a copy of this Kysely instance with the given plugin installed.
|
|
346
|
+
*/
|
|
347
|
+
withPlugin(plugin: KyselyPlugin): Transaction<DB>;
|
|
348
|
+
/**
|
|
349
|
+
* Returns a copy of this Kysely instance without any plugins.
|
|
350
|
+
*/
|
|
351
|
+
withoutPlugins(): Transaction<DB>;
|
|
352
|
+
/**
|
|
353
|
+
* Returns a copy of this Kysely instance with tables added to its
|
|
354
|
+
* database type.
|
|
355
|
+
*
|
|
356
|
+
* This method only modifies the types and doesn't affect any of the
|
|
357
|
+
* executed queries in any way.
|
|
358
|
+
*
|
|
359
|
+
* ### Examples
|
|
360
|
+
*
|
|
361
|
+
* The following example adds and uses a temporary table:
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* await db.schema
|
|
366
|
+
* .createTable('temp_table')
|
|
367
|
+
* .temporary()
|
|
368
|
+
* .addColumn('some_column', 'integer')
|
|
369
|
+
* .execute()
|
|
370
|
+
*
|
|
371
|
+
* const tempDb = db.withTables<{
|
|
372
|
+
* temp_table: {
|
|
373
|
+
* some_column: number
|
|
374
|
+
* }
|
|
375
|
+
* }>()
|
|
376
|
+
*
|
|
377
|
+
* await tempDb
|
|
378
|
+
* .insertInto('temp_table')
|
|
379
|
+
* .values({ some_column: 100 })
|
|
380
|
+
* .execute()
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
withTables<T extends Record<string, Record<string, any>>>(): Transaction<DB & T>;
|
|
225
384
|
}
|
|
226
385
|
export interface KyselyProps {
|
|
227
386
|
readonly config: KyselyConfig;
|
|
@@ -240,7 +399,8 @@ export interface KyselyConfig {
|
|
|
240
399
|
* Currently there's only two levels: `query` and `error`.
|
|
241
400
|
* This will be expanded based on user feedback later.
|
|
242
401
|
*
|
|
243
|
-
*
|
|
402
|
+
* ### Examples
|
|
403
|
+
*
|
|
244
404
|
* ```ts
|
|
245
405
|
* const db = new Kysely<Database>({
|
|
246
406
|
* dialect: new PostgresDialect(postgresConfig),
|
|
@@ -248,7 +408,6 @@ export interface KyselyConfig {
|
|
|
248
408
|
* })
|
|
249
409
|
* ```
|
|
250
410
|
*
|
|
251
|
-
* @example
|
|
252
411
|
* ```ts
|
|
253
412
|
* const db = new Kysely<Database>({
|
|
254
413
|
* dialect: new PostgresDialect(postgresConfig),
|
package/dist/esm/kysely.js
CHANGED
|
@@ -19,7 +19,8 @@ import { Log } from './util/log.js';
|
|
|
19
19
|
* You should create one instance of `Kysely` per database using the {@link Kysely}
|
|
20
20
|
* constructor. Each `Kysely` instance maintains it's own connection pool.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* ### Examples
|
|
23
|
+
*
|
|
23
24
|
* This example assumes your database has tables `person` and `pet`:
|
|
24
25
|
*
|
|
25
26
|
* ```ts
|
|
@@ -33,7 +34,7 @@ import { Log } from './util/log.js';
|
|
|
33
34
|
* id: number
|
|
34
35
|
* owner_id: number
|
|
35
36
|
* name: string
|
|
36
|
-
* species 'cat' |
|
|
37
|
+
* species 'cat' | 'dog'
|
|
37
38
|
* }
|
|
38
39
|
*
|
|
39
40
|
* interface Database {
|
|
@@ -111,10 +112,11 @@ export class Kysely extends QueryCreator {
|
|
|
111
112
|
* A value to be used in place of columns that are generated in the database
|
|
112
113
|
* when inserting rows.
|
|
113
114
|
*
|
|
114
|
-
*
|
|
115
|
+
* ### Examples
|
|
116
|
+
*
|
|
115
117
|
* In this example the `Person` table has non-null properties `id` and `created_at`
|
|
116
118
|
* which are both automatically genereted by the database. Since their types are
|
|
117
|
-
* `number` and `string` respectively instead of `number |
|
|
119
|
+
* `number` and `string` respectively instead of `number | null` and `string | null`
|
|
118
120
|
* the `values` method requires you to give a value for them. the `generated`
|
|
119
121
|
* placeholder can be used in these cases.
|
|
120
122
|
*
|
|
@@ -173,12 +175,13 @@ export class Kysely extends QueryCreator {
|
|
|
173
175
|
* transaction. If the function throws, the transaction is rolled back. Otherwise
|
|
174
176
|
* the transaction is committed.
|
|
175
177
|
*
|
|
176
|
-
* The callback function passed to the {@link TransactionBuilder.execute |
|
|
178
|
+
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
177
179
|
* method gets the transaction object as its only argument. The transaction is
|
|
178
180
|
* of type {@link Transaction} which inherits {@link Kysely}. Any query
|
|
179
181
|
* started through the transaction object is executed inside the transaction.
|
|
180
182
|
*
|
|
181
|
-
*
|
|
183
|
+
* ### Examples
|
|
184
|
+
*
|
|
182
185
|
* ```ts
|
|
183
186
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
184
187
|
* const jennifer = await trx.insertInto('person')
|
|
@@ -204,8 +207,7 @@ export class Kysely extends QueryCreator {
|
|
|
204
207
|
* })
|
|
205
208
|
* ```
|
|
206
209
|
*
|
|
207
|
-
*
|
|
208
|
-
* Setting the isolation level.
|
|
210
|
+
* Setting the isolation level:
|
|
209
211
|
*
|
|
210
212
|
* ```ts
|
|
211
213
|
* await db
|
|
@@ -222,7 +224,8 @@ export class Kysely extends QueryCreator {
|
|
|
222
224
|
/**
|
|
223
225
|
* Provides a kysely instance bound to a single database connection.
|
|
224
226
|
*
|
|
225
|
-
*
|
|
227
|
+
* ### Examples
|
|
228
|
+
*
|
|
226
229
|
* ```ts
|
|
227
230
|
* await db
|
|
228
231
|
* .connection()
|
|
@@ -255,6 +258,40 @@ export class Kysely extends QueryCreator {
|
|
|
255
258
|
executor: this.#props.executor.withoutPlugins(),
|
|
256
259
|
});
|
|
257
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Returns a copy of this Kysely instance with tables added to its
|
|
263
|
+
* database type.
|
|
264
|
+
*
|
|
265
|
+
* This method only modifies the types and doesn't affect any of the
|
|
266
|
+
* executed queries in any way.
|
|
267
|
+
*
|
|
268
|
+
* ### Examples
|
|
269
|
+
*
|
|
270
|
+
* The following example adds and uses a temporary table:
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* await db.schema
|
|
275
|
+
* .createTable('temp_table')
|
|
276
|
+
* .temporary()
|
|
277
|
+
* .addColumn('some_column', 'integer')
|
|
278
|
+
* .execute()
|
|
279
|
+
*
|
|
280
|
+
* const tempDb = db.withTables<{
|
|
281
|
+
* temp_table: {
|
|
282
|
+
* some_column: number
|
|
283
|
+
* }
|
|
284
|
+
* }>()
|
|
285
|
+
*
|
|
286
|
+
* await tempDb
|
|
287
|
+
* .insertInto('temp_table')
|
|
288
|
+
* .values({ some_column: 100 })
|
|
289
|
+
* .execute()
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
withTables() {
|
|
293
|
+
return new Kysely({ ...this.#props });
|
|
294
|
+
}
|
|
258
295
|
/**
|
|
259
296
|
* Releases all resources and disconnects from the database.
|
|
260
297
|
*
|
|
@@ -273,6 +310,11 @@ export class Kysely extends QueryCreator {
|
|
|
273
310
|
}
|
|
274
311
|
}
|
|
275
312
|
export class Transaction extends Kysely {
|
|
313
|
+
#props;
|
|
314
|
+
constructor(props) {
|
|
315
|
+
super(props);
|
|
316
|
+
this.#props = props;
|
|
317
|
+
}
|
|
276
318
|
// The return type is `true` instead of `boolean` to make Kysely<DB>
|
|
277
319
|
// unassignable to Transaction<DB> while allowing assignment the
|
|
278
320
|
// other way around.
|
|
@@ -285,9 +327,27 @@ export class Transaction extends Kysely {
|
|
|
285
327
|
transaction() {
|
|
286
328
|
throw new Error('calling the transaction method for a Transaction is not supported');
|
|
287
329
|
}
|
|
330
|
+
connection() {
|
|
331
|
+
throw new Error('calling the connection method for a Transaction is not supported');
|
|
332
|
+
}
|
|
288
333
|
async destroy() {
|
|
289
334
|
throw new Error('calling the destroy method for a Transaction is not supported');
|
|
290
335
|
}
|
|
336
|
+
withPlugin(plugin) {
|
|
337
|
+
return new Transaction({
|
|
338
|
+
...this.#props,
|
|
339
|
+
executor: this.#props.executor.withPlugin(plugin),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
withoutPlugins() {
|
|
343
|
+
return new Transaction({
|
|
344
|
+
...this.#props,
|
|
345
|
+
executor: this.#props.executor.withoutPlugins(),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
withTables() {
|
|
349
|
+
return new Transaction({ ...this.#props });
|
|
350
|
+
}
|
|
291
351
|
}
|
|
292
352
|
export function isKyselyProps(obj) {
|
|
293
353
|
return (isObject(obj) &&
|
|
@@ -3,6 +3,73 @@ import { DialectAdapter } from '../dialect/dialect-adapter.js';
|
|
|
3
3
|
export declare const MIGRATION_TABLE = "kysely_migration";
|
|
4
4
|
export declare const MIGRATION_LOCK_TABLE = "kysely_migration_lock";
|
|
5
5
|
export declare const MIGRATION_LOCK_ID = "migration_lock";
|
|
6
|
+
export declare const NO_MIGRATIONS: NoMigrations;
|
|
7
|
+
export declare type MigrationsOrFolderPath = Record<string, Migration> | string;
|
|
8
|
+
export interface Migration {
|
|
9
|
+
up(db: Kysely<any>): Promise<void>;
|
|
10
|
+
down?(db: Kysely<any>): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type for the NO_MIGRATIONS constant. Never create one of these.
|
|
14
|
+
*/
|
|
15
|
+
export interface NoMigrations {
|
|
16
|
+
readonly __noMigrations__: true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* All migration methods ({@link MigrationModule.migrateTo | migrateTo},
|
|
20
|
+
* {@link MigrationModule.migrateToLatest | migrateToLatest} etc.) never
|
|
21
|
+
* throw but return this object instead.
|
|
22
|
+
*/
|
|
23
|
+
export interface MigrationResultSet {
|
|
24
|
+
/**
|
|
25
|
+
* This is defined if something went wrong.
|
|
26
|
+
*
|
|
27
|
+
* An error may have occurred in one of the migrations in which case the
|
|
28
|
+
* {@link results} list contains an item with `status === 'Error'` to
|
|
29
|
+
* indicate which migration failed.
|
|
30
|
+
*
|
|
31
|
+
* An error may also have occurred before Kysely was able to figure out
|
|
32
|
+
* which migrations should be executed, in which case the {@link results}
|
|
33
|
+
* list is undefined.
|
|
34
|
+
*/
|
|
35
|
+
readonly error?: unknown;
|
|
36
|
+
/**
|
|
37
|
+
* {@link MigrationResult} for each individual migration that was supposed
|
|
38
|
+
* to be executed by the operation.
|
|
39
|
+
*
|
|
40
|
+
* If all went well, each result's `status` is `Success`. If some migration
|
|
41
|
+
* failed, the failed migration's result's `status` is `Error` and all
|
|
42
|
+
* results after that one have `status` ´NotExecuted`.
|
|
43
|
+
*
|
|
44
|
+
* This property can be undefined if an error occurred before Kysely was
|
|
45
|
+
* able to figure out which migrations should be executed.
|
|
46
|
+
*
|
|
47
|
+
* If this list is empty, there were no migrations to execute.
|
|
48
|
+
*/
|
|
49
|
+
readonly results?: MigrationResult[];
|
|
50
|
+
}
|
|
51
|
+
export interface MigrationResult {
|
|
52
|
+
readonly migrationName: string;
|
|
53
|
+
/**
|
|
54
|
+
* The direction in which this migration was executed.
|
|
55
|
+
*/
|
|
56
|
+
readonly direction: 'Up' | 'Down';
|
|
57
|
+
/**
|
|
58
|
+
* The execution status.
|
|
59
|
+
*
|
|
60
|
+
* - `Success` means the migration was successfully executed. Note that
|
|
61
|
+
* if any of the later migrations in the {@link MigrationResult.results}
|
|
62
|
+
* list failed (have status `Error`) AND the dialect supports transactional
|
|
63
|
+
* DDL, even the successfull migrations were rolled back.
|
|
64
|
+
*
|
|
65
|
+
* - `Error` means the migration failed. In this case the
|
|
66
|
+
* {@link MigrationResult.error} contains the error.
|
|
67
|
+
*
|
|
68
|
+
* - `NotExecuted` means that the migration was supposed to be executed
|
|
69
|
+
* but wasn't because an earlier migration failed.
|
|
70
|
+
*/
|
|
71
|
+
readonly status: 'Success' | 'Error' | 'NotExecuted';
|
|
72
|
+
}
|
|
6
73
|
export declare class MigrationModule {
|
|
7
74
|
#private;
|
|
8
75
|
constructor(db: Kysely<any>, adapter: DialectAdapter);
|
|
@@ -10,27 +77,46 @@ export declare class MigrationModule {
|
|
|
10
77
|
* Runs all migrations that have not yet been run.
|
|
11
78
|
*
|
|
12
79
|
* The only argument must either be a file path to the folder that contains all migrations
|
|
13
|
-
* OR an object that contains all migrations (not just the ones that need to be
|
|
80
|
+
* OR an object that contains all migrations (not just the ones that need to be executed).
|
|
14
81
|
* The keys in the object must be the unique migration names.
|
|
15
82
|
*
|
|
83
|
+
* This method returns a {@link MigrationResultSet} instance and _never_ throws.
|
|
84
|
+
* {@link MigrationResultSet.error} holds the error if something went wrong.
|
|
85
|
+
* {@link MigrationResultSet.results} contains information about which migrations
|
|
86
|
+
* were executed and which failed. See the examples below.
|
|
87
|
+
*
|
|
16
88
|
* This method goes through all possible migrations (passed as the argument) and runs the
|
|
17
89
|
* ones whose names are alphabetically after the last migration that has been run. If the
|
|
18
|
-
* list of executed migrations doesn't match the list of possible migrations
|
|
19
|
-
* is thrown.
|
|
90
|
+
* list of executed migrations doesn't match the beginning of the list of possible migrations
|
|
91
|
+
* an error is thrown.
|
|
92
|
+
*
|
|
93
|
+
* ### Examples
|
|
20
94
|
*
|
|
21
|
-
* @example
|
|
22
95
|
* ```ts
|
|
23
|
-
* await db.migration.migrateToLatest(
|
|
96
|
+
* const { error, results } = await db.migration.migrateToLatest(
|
|
24
97
|
* path.join(__dirname, 'migrations')
|
|
25
98
|
* )
|
|
99
|
+
*
|
|
100
|
+
* results?.forEach((it) => {
|
|
101
|
+
* if (it.status === 'Success') {
|
|
102
|
+
* console.log(`migration "${it.migrationName}" was executed successfully`)
|
|
103
|
+
* } else if (it.status === 'Error') {
|
|
104
|
+
* console.error(`failed to execute migration "${it.migrationName}"`)
|
|
105
|
+
* }
|
|
106
|
+
* })
|
|
107
|
+
*
|
|
108
|
+
* if (error) {
|
|
109
|
+
* console.error('failed to run `migrateToLatest`')
|
|
110
|
+
* console.error(error)
|
|
111
|
+
* }
|
|
26
112
|
* ```
|
|
27
113
|
*
|
|
28
114
|
* In the next example, we use a record of migration objects instead of file folder path.
|
|
29
115
|
* The keys in the object are migration names that can be anything you want. The order of
|
|
30
116
|
* the migrations is determined based on the alphabetical order of the keys in the record.
|
|
31
|
-
* This can be useful if you are using a bundler
|
|
117
|
+
* This version of the `migrateToLatest` method can be useful if you are using a bundler
|
|
118
|
+
* like webpack or esbuild.
|
|
32
119
|
*
|
|
33
|
-
* @example
|
|
34
120
|
* ```ts
|
|
35
121
|
* await db.migration.migrateToLatest({
|
|
36
122
|
* migration1: {
|
|
@@ -57,10 +143,67 @@ export declare class MigrationModule {
|
|
|
57
143
|
* })
|
|
58
144
|
* ```
|
|
59
145
|
*/
|
|
60
|
-
migrateToLatest(migrationsFolderPath: string): Promise<
|
|
61
|
-
migrateToLatest(allMigrations: Record<string, Migration>): Promise<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
146
|
+
migrateToLatest(migrationsFolderPath: string): Promise<MigrationResultSet>;
|
|
147
|
+
migrateToLatest(allMigrations: Record<string, Migration>): Promise<MigrationResultSet>;
|
|
148
|
+
/**
|
|
149
|
+
* Migrate up/down to a specific migration.
|
|
150
|
+
*
|
|
151
|
+
* Otherwise works just like {@link migrateToLatest}. The first argument
|
|
152
|
+
* behaves the same, the output is the same etc.
|
|
153
|
+
*
|
|
154
|
+
* ### Examples
|
|
155
|
+
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* await db.migration.migrateTo(
|
|
158
|
+
* path.join(__dirname, 'migrations'),
|
|
159
|
+
* 'some_migration'
|
|
160
|
+
* )
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* If you specify the name of the first migration, this method migrates
|
|
164
|
+
* down to the first migration, but doesn't run the `down` migration for
|
|
165
|
+
* the first migration. In case you want to migrate down ALL migrations
|
|
166
|
+
* you can use a special constant `NO_MIGRATIONS`:
|
|
167
|
+
*
|
|
168
|
+
* ```ts
|
|
169
|
+
* await db.migration.migrateTo(
|
|
170
|
+
* path.join(__dirname, 'migrations'),
|
|
171
|
+
* NO_MIGRATIONS,
|
|
172
|
+
* )
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
migrateTo(migrationsFolderPath: string, targetMigrationName: string | NoMigrations): Promise<MigrationResultSet>;
|
|
176
|
+
migrateTo(allMigrations: Record<string, Migration>, targetMigrationName: string | NoMigrations): Promise<MigrationResultSet>;
|
|
177
|
+
/**
|
|
178
|
+
* Migrate one step up.
|
|
179
|
+
*
|
|
180
|
+
* Otherwise works just like {@link migrateToLatest}. The only argument
|
|
181
|
+
* behaves the same, the output is the same etc.
|
|
182
|
+
*
|
|
183
|
+
* ### Examples
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* await db.migration.migrateUp(
|
|
187
|
+
* path.join(__dirname, 'migrations'),
|
|
188
|
+
* )
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
migrateUp(migrationsFolderPath: string): Promise<MigrationResultSet>;
|
|
192
|
+
migrateUp(allMigrations: Record<string, Migration>): Promise<MigrationResultSet>;
|
|
193
|
+
/**
|
|
194
|
+
* Migrate one step down.
|
|
195
|
+
*
|
|
196
|
+
* Otherwise works just like {@link migrateToLatest}. The only argument
|
|
197
|
+
* behaves the same, the output is the same etc.
|
|
198
|
+
*
|
|
199
|
+
* ### Examples
|
|
200
|
+
*
|
|
201
|
+
* ```ts
|
|
202
|
+
* await db.migration.migrateDown(
|
|
203
|
+
* path.join(__dirname, 'migrations'),
|
|
204
|
+
* )
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
migrateDown(migrationsFolderPath: string): Promise<MigrationResultSet>;
|
|
208
|
+
migrateDown(allMigrations: Record<string, Migration>): Promise<MigrationResultSet>;
|
|
66
209
|
}
|