kysely 0.27.3 → 0.27.5
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/.renovaterc.json +3 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +7 -7
- package/deno.check.d.ts +86 -0
- package/deno.check.json +21 -0
- package/dist/cjs/dialect/dialect-adapter-base.d.ts +13 -3
- package/dist/cjs/dialect/dialect-adapter-base.js +4 -1
- package/dist/cjs/dialect/dialect-adapter.d.ts +16 -2
- package/dist/cjs/dialect/mssql/mssql-adapter.d.ts +12 -7
- package/dist/cjs/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/cjs/dialect/mssql/mssql-dialect-config.d.ts +83 -55
- package/dist/cjs/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/cjs/dialect/mssql/mssql-driver.js +114 -48
- package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +11 -2
- package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +4 -0
- package/dist/cjs/dialect/mysql/mysql-driver.js +3 -0
- package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +11 -2
- package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +10 -3
- package/dist/cjs/dialect/postgres/postgres-driver.js +3 -0
- package/dist/cjs/dialect/postgres/postgres-introspector.js +5 -1
- package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +11 -2
- package/dist/cjs/driver/database-connection.d.ts +3 -1
- package/dist/cjs/driver/dummy-driver.d.ts +13 -12
- package/dist/cjs/driver/dummy-driver.js +13 -12
- package/dist/cjs/dynamic/dynamic-reference-builder.js +2 -2
- package/dist/cjs/dynamic/dynamic.d.ts +7 -7
- package/dist/cjs/dynamic/dynamic.js +7 -7
- package/dist/cjs/expression/expression-builder.d.ts +153 -62
- package/dist/cjs/expression/expression-builder.js +2 -3
- package/dist/cjs/expression/expression-wrapper.d.ts +92 -23
- package/dist/cjs/expression/expression.d.ts +40 -5
- package/dist/cjs/expression/expression.js +2 -3
- package/dist/cjs/helpers/mssql.d.ts +74 -14
- package/dist/cjs/helpers/mssql.js +77 -18
- package/dist/cjs/helpers/mysql.d.ts +17 -13
- package/dist/cjs/helpers/mysql.js +20 -17
- package/dist/cjs/helpers/postgres.d.ts +11 -8
- package/dist/cjs/helpers/postgres.js +14 -12
- package/dist/cjs/helpers/sqlite.d.ts +41 -16
- package/dist/cjs/helpers/sqlite.js +44 -20
- package/dist/cjs/index.d.ts +28 -21
- package/dist/cjs/index.js +28 -21
- package/dist/cjs/kysely.d.ts +100 -42
- package/dist/cjs/kysely.js +63 -39
- package/dist/cjs/migration/file-migration-provider.d.ts +2 -2
- package/dist/cjs/migration/file-migration-provider.js +2 -2
- package/dist/cjs/migration/migrator.d.ts +82 -14
- package/dist/cjs/migration/migrator.js +82 -14
- package/dist/cjs/operation-node/aggregate-function-node.d.ts +4 -0
- package/dist/cjs/operation-node/aggregate-function-node.js +9 -0
- package/dist/cjs/operation-node/alter-column-node.d.ts +1 -1
- package/dist/cjs/operation-node/case-node.d.ts +1 -1
- package/dist/cjs/operation-node/column-definition-node.d.ts +1 -0
- package/dist/cjs/operation-node/data-type-node.d.ts +2 -2
- package/dist/cjs/operation-node/data-type-node.js +17 -3
- package/dist/cjs/operation-node/delete-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/foreign-key-constraint-node.d.ts +4 -4
- package/dist/cjs/operation-node/having-node.d.ts +1 -1
- package/dist/cjs/operation-node/insert-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/merge-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/on-node.d.ts +1 -1
- package/dist/cjs/operation-node/operation-node-source.js +1 -2
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +11 -3
- package/dist/cjs/operation-node/operation-node-transformer.js +26 -3
- 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/operator-node.d.ts +3 -3
- package/dist/cjs/operation-node/operator-node.js +8 -6
- package/dist/cjs/operation-node/output-node.d.ts +13 -0
- package/dist/cjs/operation-node/output-node.js +26 -0
- package/dist/cjs/operation-node/query-node.d.ts +15 -6
- package/dist/cjs/operation-node/query-node.js +17 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +1 -1
- package/dist/cjs/operation-node/select-query-node.js +6 -8
- package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
- package/dist/cjs/operation-node/where-node.d.ts +1 -1
- package/dist/cjs/parser/binary-operation-parser.js +5 -6
- package/dist/cjs/parser/data-type-parser.js +1 -2
- package/dist/cjs/parser/default-value-parser.js +1 -2
- package/dist/cjs/parser/expression-parser.js +3 -4
- package/dist/cjs/parser/fetch-parser.js +1 -2
- package/dist/cjs/parser/group-by-parser.js +1 -2
- package/dist/cjs/parser/identifier-parser.js +1 -2
- package/dist/cjs/parser/insert-values-parser.js +1 -2
- package/dist/cjs/parser/join-parser.js +1 -2
- package/dist/cjs/parser/merge-parser.js +2 -3
- package/dist/cjs/parser/on-commit-action-parse.js +1 -2
- package/dist/cjs/parser/on-modify-action-parser.js +1 -2
- package/dist/cjs/parser/order-by-parser.js +3 -4
- package/dist/cjs/parser/parse-utils.js +4 -5
- package/dist/cjs/parser/partition-by-parser.js +1 -2
- package/dist/cjs/parser/reference-parser.js +8 -9
- package/dist/cjs/parser/returning-parser.d.ts +4 -3
- package/dist/cjs/parser/select-parser.js +2 -3
- package/dist/cjs/parser/set-operation-parser.js +1 -2
- package/dist/cjs/parser/table-parser.js +4 -5
- package/dist/cjs/parser/top-parser.js +1 -2
- package/dist/cjs/parser/unary-operation-parser.js +3 -4
- package/dist/cjs/parser/update-set-parser.js +2 -3
- package/dist/cjs/parser/value-parser.js +4 -5
- package/dist/cjs/parser/with-parser.js +1 -2
- package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +54 -27
- package/dist/cjs/plugin/camel-case/camel-case-plugin.js +26 -21
- package/dist/cjs/plugin/camel-case/camel-case.js +2 -3
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
- package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
- package/dist/cjs/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
- package/dist/cjs/plugin/kysely-plugin.d.ts +28 -6
- package/dist/cjs/plugin/noop-plugin.d.ts +28 -6
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
- package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
- package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +28 -6
- package/dist/cjs/query-builder/aggregate-function-builder.d.ts +43 -1
- package/dist/cjs/query-builder/aggregate-function-builder.js +30 -0
- package/dist/cjs/query-builder/delete-query-builder.d.ts +219 -43
- package/dist/cjs/query-builder/delete-query-builder.js +95 -31
- package/dist/cjs/query-builder/function-module.d.ts +40 -93
- package/dist/cjs/query-builder/function-module.js +1 -2
- package/dist/cjs/query-builder/insert-query-builder.d.ts +326 -67
- package/dist/cjs/query-builder/insert-query-builder.js +212 -61
- package/dist/cjs/query-builder/insert-result.d.ts +10 -5
- package/dist/cjs/query-builder/insert-result.js +10 -5
- package/dist/cjs/query-builder/json-path-builder.d.ts +33 -9
- package/dist/cjs/query-builder/json-path-builder.js +8 -5
- package/dist/cjs/query-builder/merge-query-builder.d.ts +312 -10
- package/dist/cjs/query-builder/merge-query-builder.js +98 -7
- package/dist/cjs/query-builder/no-result-error.js +2 -2
- package/dist/cjs/query-builder/on-conflict-builder.d.ts +53 -20
- package/dist/cjs/query-builder/on-conflict-builder.js +41 -16
- package/dist/cjs/query-builder/output-interface.d.ts +138 -0
- package/dist/cjs/query-builder/output-interface.js +2 -0
- package/dist/cjs/query-builder/returning-interface.d.ts +7 -5
- package/dist/cjs/query-builder/select-query-builder-expression.d.ts +8 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +370 -73
- package/dist/cjs/query-builder/select-query-builder.js +14 -9
- package/dist/cjs/query-builder/update-query-builder.d.ts +225 -31
- package/dist/cjs/query-builder/update-query-builder.js +96 -17
- package/dist/cjs/query-builder/update-result.d.ts +9 -0
- package/dist/cjs/query-builder/update-result.js +9 -0
- package/dist/cjs/query-builder/where-interface.d.ts +6 -2
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +45 -1
- package/dist/cjs/query-creator.d.ts +122 -21
- package/dist/cjs/query-creator.js +56 -3
- package/dist/cjs/raw-builder/raw-builder.d.ts +29 -7
- package/dist/cjs/raw-builder/raw-builder.js +1 -2
- package/dist/cjs/raw-builder/sql.d.ts +31 -12
- package/dist/cjs/schema/alter-column-builder.d.ts +17 -3
- package/dist/cjs/schema/alter-column-builder.js +20 -3
- package/dist/cjs/schema/alter-table-add-index-builder.d.ts +44 -10
- package/dist/cjs/schema/alter-table-add-index-builder.js +27 -10
- package/dist/cjs/schema/alter-table-builder.js +1 -2
- package/dist/cjs/schema/column-definition-builder.d.ts +286 -24
- package/dist/cjs/schema/column-definition-builder.js +288 -24
- package/dist/cjs/schema/create-table-builder.d.ts +86 -33
- package/dist/cjs/schema/create-table-builder.js +86 -33
- package/dist/cjs/util/assert.js +2 -3
- package/dist/cjs/util/column-type.d.ts +5 -9
- package/dist/cjs/util/compilable.js +1 -2
- package/dist/cjs/util/json-object-args.js +1 -2
- package/dist/cjs/util/log-once.js +1 -2
- package/dist/cjs/util/object-utils.js +38 -26
- package/dist/cjs/util/performance-now.js +1 -2
- package/dist/cjs/util/prevent-await.js +1 -2
- package/dist/cjs/util/query-id.js +1 -2
- package/dist/cjs/util/random-string.js +1 -2
- package/dist/cjs/util/require-all-props.d.ts +4 -2
- package/dist/cjs/util/require-all-props.js +5 -4
- package/dist/cjs/util/stack-trace-utils.js +1 -2
- package/dist/cjs/util/streamable.d.ts +1 -1
- package/dist/cjs/util/type-utils.d.ts +4 -2
- package/dist/esm/dialect/dialect-adapter-base.d.ts +13 -3
- package/dist/esm/dialect/dialect-adapter-base.js +4 -1
- package/dist/esm/dialect/dialect-adapter.d.ts +16 -2
- package/dist/esm/dialect/mssql/mssql-adapter.d.ts +12 -7
- package/dist/esm/dialect/mssql/mssql-adapter.js +2 -4
- package/dist/esm/dialect/mssql/mssql-dialect-config.d.ts +83 -55
- package/dist/esm/dialect/mssql/mssql-driver.d.ts +1 -0
- package/dist/esm/dialect/mssql/mssql-driver.js +114 -48
- package/dist/esm/dialect/mysql/mysql-adapter.d.ts +11 -2
- package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +4 -0
- package/dist/esm/dialect/mysql/mysql-driver.js +3 -0
- package/dist/esm/dialect/postgres/postgres-adapter.d.ts +11 -2
- package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +10 -3
- package/dist/esm/dialect/postgres/postgres-driver.js +3 -0
- package/dist/esm/dialect/postgres/postgres-introspector.js +5 -1
- package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +11 -2
- package/dist/esm/driver/database-connection.d.ts +3 -1
- package/dist/esm/driver/dummy-driver.d.ts +13 -12
- package/dist/esm/driver/dummy-driver.js +13 -12
- package/dist/esm/dynamic/dynamic.d.ts +7 -7
- package/dist/esm/dynamic/dynamic.js +7 -7
- package/dist/esm/expression/expression-builder.d.ts +153 -62
- package/dist/esm/expression/expression-wrapper.d.ts +92 -23
- package/dist/esm/expression/expression.d.ts +40 -5
- package/dist/esm/helpers/mssql.d.ts +74 -14
- package/dist/esm/helpers/mssql.js +74 -14
- package/dist/esm/helpers/mysql.d.ts +17 -13
- package/dist/esm/helpers/mysql.js +17 -13
- package/dist/esm/helpers/postgres.d.ts +11 -8
- package/dist/esm/helpers/postgres.js +11 -8
- package/dist/esm/helpers/sqlite.d.ts +41 -16
- package/dist/esm/helpers/sqlite.js +41 -16
- package/dist/esm/index.d.ts +28 -21
- package/dist/esm/index.js +28 -21
- package/dist/esm/kysely.d.ts +100 -42
- package/dist/esm/kysely.js +61 -37
- package/dist/esm/migration/file-migration-provider.d.ts +2 -2
- package/dist/esm/migration/file-migration-provider.js +2 -2
- package/dist/esm/migration/migrator.d.ts +82 -14
- package/dist/esm/migration/migrator.js +82 -14
- package/dist/esm/operation-node/aggregate-function-node.d.ts +4 -0
- package/dist/esm/operation-node/aggregate-function-node.js +9 -0
- package/dist/esm/operation-node/alter-column-node.d.ts +1 -1
- package/dist/esm/operation-node/case-node.d.ts +1 -1
- package/dist/esm/operation-node/column-definition-node.d.ts +1 -0
- package/dist/esm/operation-node/data-type-node.d.ts +2 -2
- package/dist/esm/operation-node/data-type-node.js +15 -1
- package/dist/esm/operation-node/delete-query-node.d.ts +3 -0
- package/dist/esm/operation-node/foreign-key-constraint-node.d.ts +4 -4
- package/dist/esm/operation-node/having-node.d.ts +1 -1
- package/dist/esm/operation-node/insert-query-node.d.ts +3 -0
- package/dist/esm/operation-node/merge-query-node.d.ts +3 -0
- package/dist/esm/operation-node/on-node.d.ts +1 -1
- package/dist/esm/operation-node/operation-node-transformer.d.ts +11 -3
- package/dist/esm/operation-node/operation-node-transformer.js +26 -3
- 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/operator-node.d.ts +3 -3
- package/dist/esm/operation-node/operator-node.js +2 -0
- package/dist/esm/operation-node/output-node.d.ts +13 -0
- package/dist/esm/operation-node/output-node.js +24 -0
- package/dist/esm/operation-node/query-node.d.ts +15 -6
- package/dist/esm/operation-node/query-node.js +17 -0
- package/dist/esm/operation-node/select-query-node.d.ts +1 -1
- package/dist/esm/operation-node/select-query-node.js +6 -8
- package/dist/esm/operation-node/update-query-node.d.ts +3 -0
- package/dist/esm/operation-node/where-node.d.ts +1 -1
- package/dist/esm/parser/returning-parser.d.ts +4 -3
- package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +54 -27
- package/dist/esm/plugin/camel-case/camel-case-plugin.js +26 -21
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
- package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
- package/dist/esm/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
- package/dist/esm/plugin/kysely-plugin.d.ts +28 -6
- package/dist/esm/plugin/noop-plugin.d.ts +28 -6
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
- package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
- package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +28 -6
- package/dist/esm/query-builder/aggregate-function-builder.d.ts +43 -1
- package/dist/esm/query-builder/aggregate-function-builder.js +30 -0
- package/dist/esm/query-builder/delete-query-builder.d.ts +219 -43
- package/dist/esm/query-builder/delete-query-builder.js +95 -31
- package/dist/esm/query-builder/function-module.d.ts +40 -93
- package/dist/esm/query-builder/insert-query-builder.d.ts +326 -67
- package/dist/esm/query-builder/insert-query-builder.js +212 -61
- package/dist/esm/query-builder/insert-result.d.ts +10 -5
- package/dist/esm/query-builder/insert-result.js +10 -5
- package/dist/esm/query-builder/json-path-builder.d.ts +33 -9
- package/dist/esm/query-builder/json-path-builder.js +8 -5
- package/dist/esm/query-builder/merge-query-builder.d.ts +312 -10
- package/dist/esm/query-builder/merge-query-builder.js +98 -7
- package/dist/esm/query-builder/on-conflict-builder.d.ts +53 -20
- package/dist/esm/query-builder/on-conflict-builder.js +41 -16
- package/dist/esm/query-builder/output-interface.d.ts +138 -0
- package/dist/esm/query-builder/output-interface.js +2 -0
- package/dist/esm/query-builder/returning-interface.d.ts +7 -5
- package/dist/esm/query-builder/select-query-builder-expression.d.ts +8 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +370 -73
- package/dist/esm/query-builder/select-query-builder.js +13 -7
- package/dist/esm/query-builder/update-query-builder.d.ts +225 -31
- package/dist/esm/query-builder/update-query-builder.js +96 -17
- package/dist/esm/query-builder/update-result.d.ts +9 -0
- package/dist/esm/query-builder/update-result.js +9 -0
- package/dist/esm/query-builder/where-interface.d.ts +6 -2
- package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
- package/dist/esm/query-compiler/default-query-compiler.js +45 -1
- package/dist/esm/query-creator.d.ts +122 -21
- package/dist/esm/query-creator.js +56 -3
- package/dist/esm/raw-builder/raw-builder.d.ts +29 -7
- package/dist/esm/raw-builder/sql.d.ts +31 -12
- package/dist/esm/schema/alter-column-builder.d.ts +17 -3
- package/dist/esm/schema/alter-column-builder.js +20 -3
- package/dist/esm/schema/alter-table-add-index-builder.d.ts +44 -10
- package/dist/esm/schema/alter-table-add-index-builder.js +27 -10
- package/dist/esm/schema/alter-table-builder.js +1 -2
- package/dist/esm/schema/column-definition-builder.d.ts +286 -24
- package/dist/esm/schema/column-definition-builder.js +288 -24
- package/dist/esm/schema/create-table-builder.d.ts +86 -33
- package/dist/esm/schema/create-table-builder.js +86 -33
- package/dist/esm/util/column-type.d.ts +5 -9
- package/dist/esm/util/object-utils.js +18 -5
- package/dist/esm/util/require-all-props.d.ts +4 -2
- package/dist/esm/util/require-all-props.js +4 -2
- package/dist/esm/util/streamable.d.ts +1 -1
- package/dist/esm/util/type-utils.d.ts +4 -2
- package/package.json +30 -24
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { ExpressionBuilder, expressionBuilder, } from './expression/expression-b
|
|
|
5
5
|
export * from './expression/expression-wrapper.js';
|
|
6
6
|
export * from './query-builder/where-interface.js';
|
|
7
7
|
export * from './query-builder/returning-interface.js';
|
|
8
|
+
export * from './query-builder/output-interface.js';
|
|
8
9
|
export * from './query-builder/having-interface.js';
|
|
9
10
|
export * from './query-builder/select-query-builder.js';
|
|
10
11
|
export * from './query-builder/insert-query-builder.js';
|
|
@@ -91,17 +92,21 @@ export * from './plugin/with-schema/with-schema-plugin.js';
|
|
|
91
92
|
export * from './plugin/parse-json-results/parse-json-results-plugin.js';
|
|
92
93
|
export * from './operation-node/add-column-node.js';
|
|
93
94
|
export * from './operation-node/add-constraint-node.js';
|
|
95
|
+
export * from './operation-node/add-index-node.js';
|
|
96
|
+
export * from './operation-node/aggregate-function-node.js';
|
|
94
97
|
export * from './operation-node/alias-node.js';
|
|
95
98
|
export * from './operation-node/alter-column-node.js';
|
|
96
99
|
export * from './operation-node/alter-table-node.js';
|
|
97
100
|
export * from './operation-node/and-node.js';
|
|
101
|
+
export * from './operation-node/binary-operation-node.js';
|
|
98
102
|
export * from './operation-node/case-node.js';
|
|
103
|
+
export * from './operation-node/cast-node.js';
|
|
99
104
|
export * from './operation-node/check-constraint-node.js';
|
|
100
105
|
export * from './operation-node/column-definition-node.js';
|
|
101
106
|
export * from './operation-node/column-node.js';
|
|
102
107
|
export * from './operation-node/column-update-node.js';
|
|
103
|
-
export * from './operation-node/common-table-expression-node.js';
|
|
104
108
|
export * from './operation-node/common-table-expression-name-node.js';
|
|
109
|
+
export * from './operation-node/common-table-expression-node.js';
|
|
105
110
|
export * from './operation-node/constraint-node.js';
|
|
106
111
|
export * from './operation-node/create-index-node.js';
|
|
107
112
|
export * from './operation-node/create-schema-node.js';
|
|
@@ -109,6 +114,7 @@ export * from './operation-node/create-table-node.js';
|
|
|
109
114
|
export * from './operation-node/create-type-node.js';
|
|
110
115
|
export * from './operation-node/create-view-node.js';
|
|
111
116
|
export * from './operation-node/data-type-node.js';
|
|
117
|
+
export * from './operation-node/default-insert-value-node.js';
|
|
112
118
|
export * from './operation-node/default-value-node.js';
|
|
113
119
|
export * from './operation-node/delete-query-node.js';
|
|
114
120
|
export * from './operation-node/drop-column-node.js';
|
|
@@ -118,8 +124,11 @@ export * from './operation-node/drop-schema-node.js';
|
|
|
118
124
|
export * from './operation-node/drop-table-node.js';
|
|
119
125
|
export * from './operation-node/drop-type-node.js';
|
|
120
126
|
export * from './operation-node/drop-view-node.js';
|
|
127
|
+
export * from './operation-node/explain-node.js';
|
|
128
|
+
export * from './operation-node/fetch-node.js';
|
|
121
129
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
122
130
|
export * from './operation-node/from-node.js';
|
|
131
|
+
export * from './operation-node/function-node.js';
|
|
123
132
|
export * from './operation-node/generated-node.js';
|
|
124
133
|
export * from './operation-node/group-by-item-node.js';
|
|
125
134
|
export * from './operation-node/group-by-node.js';
|
|
@@ -127,8 +136,14 @@ export * from './operation-node/having-node.js';
|
|
|
127
136
|
export * from './operation-node/identifier-node.js';
|
|
128
137
|
export * from './operation-node/insert-query-node.js';
|
|
129
138
|
export * from './operation-node/join-node.js';
|
|
139
|
+
export * from './operation-node/json-operator-chain-node.js';
|
|
140
|
+
export * from './operation-node/json-path-leg-node.js';
|
|
141
|
+
export * from './operation-node/json-path-node.js';
|
|
142
|
+
export * from './operation-node/json-reference-node.js';
|
|
130
143
|
export * from './operation-node/limit-node.js';
|
|
131
144
|
export * from './operation-node/list-node.js';
|
|
145
|
+
export * from './operation-node/matched-node.js';
|
|
146
|
+
export * from './operation-node/merge-query-node.js';
|
|
132
147
|
export * from './operation-node/modify-column-node.js';
|
|
133
148
|
export * from './operation-node/offset-node.js';
|
|
134
149
|
export * from './operation-node/on-conflict-node.js';
|
|
@@ -142,7 +157,11 @@ export * from './operation-node/operator-node.js';
|
|
|
142
157
|
export * from './operation-node/or-node.js';
|
|
143
158
|
export * from './operation-node/order-by-item-node.js';
|
|
144
159
|
export * from './operation-node/order-by-node.js';
|
|
160
|
+
export * from './operation-node/output-node.js';
|
|
161
|
+
export * from './operation-node/over-node.js';
|
|
145
162
|
export * from './operation-node/parens-node.js';
|
|
163
|
+
export * from './operation-node/partition-by-item-node.js';
|
|
164
|
+
export * from './operation-node/partition-by-node.js';
|
|
146
165
|
export * from './operation-node/primary-constraint-node.js';
|
|
147
166
|
export * from './operation-node/primitive-value-list-node.js';
|
|
148
167
|
export * from './operation-node/query-node.js';
|
|
@@ -151,38 +170,26 @@ export * from './operation-node/reference-node.js';
|
|
|
151
170
|
export * from './operation-node/references-node.js';
|
|
152
171
|
export * from './operation-node/rename-column-node.js';
|
|
153
172
|
export * from './operation-node/returning-node.js';
|
|
173
|
+
export * from './operation-node/schemable-identifier-node.js';
|
|
154
174
|
export * from './operation-node/select-all-node.js';
|
|
155
|
-
export * from './operation-node/select-
|
|
175
|
+
export * from './operation-node/select-modifier-node.js';
|
|
156
176
|
export * from './operation-node/select-query-node.js';
|
|
157
177
|
export * from './operation-node/selection-node.js';
|
|
178
|
+
export * from './operation-node/set-operation-node.js';
|
|
179
|
+
export * from './operation-node/simple-reference-expression-node.js';
|
|
158
180
|
export * from './operation-node/table-node.js';
|
|
181
|
+
export * from './operation-node/top-node.js';
|
|
182
|
+
export * from './operation-node/tuple-node.js';
|
|
183
|
+
export * from './operation-node/unary-operation-node.js';
|
|
159
184
|
export * from './operation-node/unique-constraint-node.js';
|
|
160
185
|
export * from './operation-node/update-query-node.js';
|
|
186
|
+
export * from './operation-node/using-node.js';
|
|
161
187
|
export * from './operation-node/value-list-node.js';
|
|
162
188
|
export * from './operation-node/value-node.js';
|
|
163
189
|
export * from './operation-node/values-node.js';
|
|
164
190
|
export * from './operation-node/when-node.js';
|
|
165
191
|
export * from './operation-node/where-node.js';
|
|
166
192
|
export * from './operation-node/with-node.js';
|
|
167
|
-
export * from './operation-node/explain-node.js';
|
|
168
|
-
export * from './operation-node/default-insert-value-node.js';
|
|
169
|
-
export * from './operation-node/aggregate-function-node.js';
|
|
170
|
-
export * from './operation-node/over-node.js';
|
|
171
|
-
export * from './operation-node/partition-by-node.js';
|
|
172
|
-
export * from './operation-node/partition-by-item-node.js';
|
|
173
|
-
export * from './operation-node/set-operation-node.js';
|
|
174
|
-
export * from './operation-node/binary-operation-node.js';
|
|
175
|
-
export * from './operation-node/unary-operation-node.js';
|
|
176
|
-
export * from './operation-node/using-node.js';
|
|
177
|
-
export * from './operation-node/json-reference-node.js';
|
|
178
|
-
export * from './operation-node/json-path-leg-node.js';
|
|
179
|
-
export * from './operation-node/json-path-node.js';
|
|
180
|
-
export * from './operation-node/json-operator-chain-node.js';
|
|
181
|
-
export * from './operation-node/tuple-node.js';
|
|
182
|
-
export * from './operation-node/merge-query-node.js';
|
|
183
|
-
export * from './operation-node/matched-node.js';
|
|
184
|
-
export * from './operation-node/fetch-node.js';
|
|
185
|
-
export * from './operation-node/top-node.js';
|
|
186
193
|
export * from './util/column-type.js';
|
|
187
194
|
export * from './util/compilable.js';
|
|
188
195
|
export * from './util/explainable.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { expressionBuilder, } from './expression/expression-builder.js';
|
|
|
6
6
|
export * from './expression/expression-wrapper.js';
|
|
7
7
|
export * from './query-builder/where-interface.js';
|
|
8
8
|
export * from './query-builder/returning-interface.js';
|
|
9
|
+
export * from './query-builder/output-interface.js';
|
|
9
10
|
export * from './query-builder/having-interface.js';
|
|
10
11
|
export * from './query-builder/select-query-builder.js';
|
|
11
12
|
export * from './query-builder/insert-query-builder.js';
|
|
@@ -92,17 +93,21 @@ export * from './plugin/with-schema/with-schema-plugin.js';
|
|
|
92
93
|
export * from './plugin/parse-json-results/parse-json-results-plugin.js';
|
|
93
94
|
export * from './operation-node/add-column-node.js';
|
|
94
95
|
export * from './operation-node/add-constraint-node.js';
|
|
96
|
+
export * from './operation-node/add-index-node.js';
|
|
97
|
+
export * from './operation-node/aggregate-function-node.js';
|
|
95
98
|
export * from './operation-node/alias-node.js';
|
|
96
99
|
export * from './operation-node/alter-column-node.js';
|
|
97
100
|
export * from './operation-node/alter-table-node.js';
|
|
98
101
|
export * from './operation-node/and-node.js';
|
|
102
|
+
export * from './operation-node/binary-operation-node.js';
|
|
99
103
|
export * from './operation-node/case-node.js';
|
|
104
|
+
export * from './operation-node/cast-node.js';
|
|
100
105
|
export * from './operation-node/check-constraint-node.js';
|
|
101
106
|
export * from './operation-node/column-definition-node.js';
|
|
102
107
|
export * from './operation-node/column-node.js';
|
|
103
108
|
export * from './operation-node/column-update-node.js';
|
|
104
|
-
export * from './operation-node/common-table-expression-node.js';
|
|
105
109
|
export * from './operation-node/common-table-expression-name-node.js';
|
|
110
|
+
export * from './operation-node/common-table-expression-node.js';
|
|
106
111
|
export * from './operation-node/constraint-node.js';
|
|
107
112
|
export * from './operation-node/create-index-node.js';
|
|
108
113
|
export * from './operation-node/create-schema-node.js';
|
|
@@ -110,6 +115,7 @@ export * from './operation-node/create-table-node.js';
|
|
|
110
115
|
export * from './operation-node/create-type-node.js';
|
|
111
116
|
export * from './operation-node/create-view-node.js';
|
|
112
117
|
export * from './operation-node/data-type-node.js';
|
|
118
|
+
export * from './operation-node/default-insert-value-node.js';
|
|
113
119
|
export * from './operation-node/default-value-node.js';
|
|
114
120
|
export * from './operation-node/delete-query-node.js';
|
|
115
121
|
export * from './operation-node/drop-column-node.js';
|
|
@@ -119,8 +125,11 @@ export * from './operation-node/drop-schema-node.js';
|
|
|
119
125
|
export * from './operation-node/drop-table-node.js';
|
|
120
126
|
export * from './operation-node/drop-type-node.js';
|
|
121
127
|
export * from './operation-node/drop-view-node.js';
|
|
128
|
+
export * from './operation-node/explain-node.js';
|
|
129
|
+
export * from './operation-node/fetch-node.js';
|
|
122
130
|
export * from './operation-node/foreign-key-constraint-node.js';
|
|
123
131
|
export * from './operation-node/from-node.js';
|
|
132
|
+
export * from './operation-node/function-node.js';
|
|
124
133
|
export * from './operation-node/generated-node.js';
|
|
125
134
|
export * from './operation-node/group-by-item-node.js';
|
|
126
135
|
export * from './operation-node/group-by-node.js';
|
|
@@ -128,8 +137,14 @@ export * from './operation-node/having-node.js';
|
|
|
128
137
|
export * from './operation-node/identifier-node.js';
|
|
129
138
|
export * from './operation-node/insert-query-node.js';
|
|
130
139
|
export * from './operation-node/join-node.js';
|
|
140
|
+
export * from './operation-node/json-operator-chain-node.js';
|
|
141
|
+
export * from './operation-node/json-path-leg-node.js';
|
|
142
|
+
export * from './operation-node/json-path-node.js';
|
|
143
|
+
export * from './operation-node/json-reference-node.js';
|
|
131
144
|
export * from './operation-node/limit-node.js';
|
|
132
145
|
export * from './operation-node/list-node.js';
|
|
146
|
+
export * from './operation-node/matched-node.js';
|
|
147
|
+
export * from './operation-node/merge-query-node.js';
|
|
133
148
|
export * from './operation-node/modify-column-node.js';
|
|
134
149
|
export * from './operation-node/offset-node.js';
|
|
135
150
|
export * from './operation-node/on-conflict-node.js';
|
|
@@ -143,7 +158,11 @@ export * from './operation-node/operator-node.js';
|
|
|
143
158
|
export * from './operation-node/or-node.js';
|
|
144
159
|
export * from './operation-node/order-by-item-node.js';
|
|
145
160
|
export * from './operation-node/order-by-node.js';
|
|
161
|
+
export * from './operation-node/output-node.js';
|
|
162
|
+
export * from './operation-node/over-node.js';
|
|
146
163
|
export * from './operation-node/parens-node.js';
|
|
164
|
+
export * from './operation-node/partition-by-item-node.js';
|
|
165
|
+
export * from './operation-node/partition-by-node.js';
|
|
147
166
|
export * from './operation-node/primary-constraint-node.js';
|
|
148
167
|
export * from './operation-node/primitive-value-list-node.js';
|
|
149
168
|
export * from './operation-node/query-node.js';
|
|
@@ -152,38 +171,26 @@ export * from './operation-node/reference-node.js';
|
|
|
152
171
|
export * from './operation-node/references-node.js';
|
|
153
172
|
export * from './operation-node/rename-column-node.js';
|
|
154
173
|
export * from './operation-node/returning-node.js';
|
|
174
|
+
export * from './operation-node/schemable-identifier-node.js';
|
|
155
175
|
export * from './operation-node/select-all-node.js';
|
|
156
|
-
export * from './operation-node/select-
|
|
176
|
+
export * from './operation-node/select-modifier-node.js';
|
|
157
177
|
export * from './operation-node/select-query-node.js';
|
|
158
178
|
export * from './operation-node/selection-node.js';
|
|
179
|
+
export * from './operation-node/set-operation-node.js';
|
|
180
|
+
export * from './operation-node/simple-reference-expression-node.js';
|
|
159
181
|
export * from './operation-node/table-node.js';
|
|
182
|
+
export * from './operation-node/top-node.js';
|
|
183
|
+
export * from './operation-node/tuple-node.js';
|
|
184
|
+
export * from './operation-node/unary-operation-node.js';
|
|
160
185
|
export * from './operation-node/unique-constraint-node.js';
|
|
161
186
|
export * from './operation-node/update-query-node.js';
|
|
187
|
+
export * from './operation-node/using-node.js';
|
|
162
188
|
export * from './operation-node/value-list-node.js';
|
|
163
189
|
export * from './operation-node/value-node.js';
|
|
164
190
|
export * from './operation-node/values-node.js';
|
|
165
191
|
export * from './operation-node/when-node.js';
|
|
166
192
|
export * from './operation-node/where-node.js';
|
|
167
193
|
export * from './operation-node/with-node.js';
|
|
168
|
-
export * from './operation-node/explain-node.js';
|
|
169
|
-
export * from './operation-node/default-insert-value-node.js';
|
|
170
|
-
export * from './operation-node/aggregate-function-node.js';
|
|
171
|
-
export * from './operation-node/over-node.js';
|
|
172
|
-
export * from './operation-node/partition-by-node.js';
|
|
173
|
-
export * from './operation-node/partition-by-item-node.js';
|
|
174
|
-
export * from './operation-node/set-operation-node.js';
|
|
175
|
-
export * from './operation-node/binary-operation-node.js';
|
|
176
|
-
export * from './operation-node/unary-operation-node.js';
|
|
177
|
-
export * from './operation-node/using-node.js';
|
|
178
|
-
export * from './operation-node/json-reference-node.js';
|
|
179
|
-
export * from './operation-node/json-path-leg-node.js';
|
|
180
|
-
export * from './operation-node/json-path-node.js';
|
|
181
|
-
export * from './operation-node/json-operator-chain-node.js';
|
|
182
|
-
export * from './operation-node/tuple-node.js';
|
|
183
|
-
export * from './operation-node/merge-query-node.js';
|
|
184
|
-
export * from './operation-node/matched-node.js';
|
|
185
|
-
export * from './operation-node/fetch-node.js';
|
|
186
|
-
export * from './operation-node/top-node.js';
|
|
187
194
|
export * from './util/column-type.js';
|
|
188
195
|
export * from './util/compilable.js';
|
|
189
196
|
export * from './util/explainable.js';
|
package/dist/esm/kysely.d.ts
CHANGED
|
@@ -20,37 +20,27 @@ import { DrainOuterGeneric } from './util/type-utils.js';
|
|
|
20
20
|
* The main Kysely class.
|
|
21
21
|
*
|
|
22
22
|
* You should create one instance of `Kysely` per database using the {@link Kysely}
|
|
23
|
-
* constructor. Each `Kysely` instance maintains
|
|
23
|
+
* constructor. Each `Kysely` instance maintains its own connection pool.
|
|
24
24
|
*
|
|
25
25
|
* ### Examples
|
|
26
26
|
*
|
|
27
|
-
* This example assumes your database has
|
|
27
|
+
* This example assumes your database has a "person" table:
|
|
28
28
|
*
|
|
29
29
|
* ```ts
|
|
30
|
-
* import
|
|
31
|
-
*
|
|
32
|
-
* interface PersonTable {
|
|
33
|
-
* id: Generated<number>
|
|
34
|
-
* first_name: string
|
|
35
|
-
* last_name: string
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* interface PetTable {
|
|
39
|
-
* id: Generated<number>
|
|
40
|
-
* owner_id: number
|
|
41
|
-
* name: string
|
|
42
|
-
* species: 'cat' | 'dog'
|
|
43
|
-
* }
|
|
30
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
31
|
+
* import { type Generated, Kysely, SqliteDialect } from 'kysely'
|
|
44
32
|
*
|
|
45
33
|
* interface Database {
|
|
46
|
-
* person:
|
|
47
|
-
*
|
|
34
|
+
* person: {
|
|
35
|
+
* id: Generated<number>
|
|
36
|
+
* first_name: string
|
|
37
|
+
* last_name: string | null
|
|
38
|
+
* }
|
|
48
39
|
* }
|
|
49
40
|
*
|
|
50
41
|
* const db = new Kysely<Database>({
|
|
51
|
-
* dialect: new
|
|
52
|
-
*
|
|
53
|
-
* database: 'kysely_test',
|
|
42
|
+
* dialect: new SqliteDialect({
|
|
43
|
+
* database: new Sqlite(':memory:'),
|
|
54
44
|
* })
|
|
55
45
|
* })
|
|
56
46
|
* ```
|
|
@@ -86,30 +76,52 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
86
76
|
case(): CaseBuilder<DB, keyof DB>;
|
|
87
77
|
case<V>(value: Expression<V>): CaseBuilder<DB, keyof DB, V>;
|
|
88
78
|
/**
|
|
89
|
-
* Returns a {@link FunctionModule} that can be used to write type
|
|
79
|
+
* Returns a {@link FunctionModule} that can be used to write somewhat type-safe function
|
|
90
80
|
* calls.
|
|
91
81
|
*
|
|
92
82
|
* ```ts
|
|
83
|
+
* const { count } = db.fn
|
|
84
|
+
*
|
|
93
85
|
* await db.selectFrom('person')
|
|
94
86
|
* .innerJoin('pet', 'pet.owner_id', 'person.id')
|
|
95
|
-
* .select(
|
|
96
|
-
* '
|
|
97
|
-
*
|
|
87
|
+
* .select([
|
|
88
|
+
* 'id',
|
|
89
|
+
* count('pet.id').as('person_count'),
|
|
98
90
|
* ])
|
|
99
91
|
* .groupBy('person.id')
|
|
100
|
-
* .having(
|
|
92
|
+
* .having(count('pet.id'), '>', 10)
|
|
101
93
|
* .execute()
|
|
102
94
|
* ```
|
|
103
95
|
*
|
|
104
96
|
* The generated SQL (PostgreSQL):
|
|
105
97
|
*
|
|
106
98
|
* ```sql
|
|
107
|
-
* select "person"."id", count("pet"."id") as "
|
|
99
|
+
* select "person"."id", count("pet"."id") as "person_count"
|
|
108
100
|
* from "person"
|
|
109
101
|
* inner join "pet" on "pet"."owner_id" = "person"."id"
|
|
110
102
|
* group by "person"."id"
|
|
111
103
|
* having count("pet"."id") > $1
|
|
112
104
|
* ```
|
|
105
|
+
*
|
|
106
|
+
* Why "somewhat" type-safe? Because the function calls are not bound to the
|
|
107
|
+
* current query context. They allow you to reference columns and tables that
|
|
108
|
+
* are not in the current query. E.g. remove the `innerJoin` from the previous
|
|
109
|
+
* query and TypeScript won't even complain.
|
|
110
|
+
*
|
|
111
|
+
* If you want to make the function calls fully type-safe, you can use the
|
|
112
|
+
* {@link ExpressionBuilder.fn} getter for a query context-aware, stricter {@link FunctionModule}.
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* await db.selectFrom('person')
|
|
116
|
+
* .innerJoin('pet', 'pet.owner_id', 'person.id')
|
|
117
|
+
* .select((eb) => [
|
|
118
|
+
* 'person.id',
|
|
119
|
+
* eb.fn.count('pet.id').as('pet_count')
|
|
120
|
+
* ])
|
|
121
|
+
* .groupBy('person.id')
|
|
122
|
+
* .having((eb) => eb.fn.count('pet.id'), '>', 10)
|
|
123
|
+
* .execute()
|
|
124
|
+
* ```
|
|
113
125
|
*/
|
|
114
126
|
get fn(): FunctionModule<DB, keyof DB>;
|
|
115
127
|
/**
|
|
@@ -118,8 +130,11 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
118
130
|
* The returned {@link TransactionBuilder} can be used to configure the transaction. The
|
|
119
131
|
* {@link TransactionBuilder.execute} method can then be called to run the transaction.
|
|
120
132
|
* {@link TransactionBuilder.execute} takes a function that is run inside the
|
|
121
|
-
* transaction. If the function throws
|
|
122
|
-
* the
|
|
133
|
+
* transaction. If the function throws an exception,
|
|
134
|
+
* 1. the exception is caught,
|
|
135
|
+
* 2. the transaction is rolled back, and
|
|
136
|
+
* 3. the exception is thrown again.
|
|
137
|
+
* Otherwise the transaction is committed.
|
|
123
138
|
*
|
|
124
139
|
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
125
140
|
* method gets the transaction object as its only argument. The transaction is
|
|
@@ -130,9 +145,12 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
130
145
|
*
|
|
131
146
|
* <!-- siteExample("transactions", "Simple transaction", 10) -->
|
|
132
147
|
*
|
|
133
|
-
* This example inserts two rows in a transaction. If an
|
|
134
|
-
* the callback passed to the `execute` method,
|
|
135
|
-
*
|
|
148
|
+
* This example inserts two rows in a transaction. If an exception is thrown inside
|
|
149
|
+
* the callback passed to the `execute` method,
|
|
150
|
+
* 1. the exception is caught,
|
|
151
|
+
* 2. the transaction is rolled back, and
|
|
152
|
+
* 3. the exception is thrown again.
|
|
153
|
+
* Otherwise the transaction is committed.
|
|
136
154
|
*
|
|
137
155
|
* ```ts
|
|
138
156
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
@@ -160,12 +178,18 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
160
178
|
* Setting the isolation level:
|
|
161
179
|
*
|
|
162
180
|
* ```ts
|
|
181
|
+
* import type { Kysely } from 'kysely'
|
|
182
|
+
*
|
|
163
183
|
* await db
|
|
164
184
|
* .transaction()
|
|
165
185
|
* .setIsolationLevel('serializable')
|
|
166
186
|
* .execute(async (trx) => {
|
|
167
187
|
* await doStuff(trx)
|
|
168
188
|
* })
|
|
189
|
+
*
|
|
190
|
+
* async function doStuff(kysely: typeof db) {
|
|
191
|
+
* // ...
|
|
192
|
+
* }
|
|
169
193
|
* ```
|
|
170
194
|
*/
|
|
171
195
|
transaction(): TransactionBuilder<DB>;
|
|
@@ -183,6 +207,10 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
183
207
|
* // the same connection.
|
|
184
208
|
* await doStuff(db)
|
|
185
209
|
* })
|
|
210
|
+
*
|
|
211
|
+
* async function doStuff(kysely: typeof db) {
|
|
212
|
+
* // ...
|
|
213
|
+
* }
|
|
186
214
|
* ```
|
|
187
215
|
*/
|
|
188
216
|
connection(): ConnectionBuilder<DB>;
|
|
@@ -209,7 +237,6 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
209
237
|
*
|
|
210
238
|
* The following example adds and uses a temporary table:
|
|
211
239
|
*
|
|
212
|
-
* @example
|
|
213
240
|
* ```ts
|
|
214
241
|
* await db.schema
|
|
215
242
|
* .createTable('temp_table')
|
|
@@ -250,7 +277,7 @@ export declare class Kysely<DB> extends QueryCreator<DB> implements QueryExecuto
|
|
|
250
277
|
/**
|
|
251
278
|
* Executes a given compiled query or query builder.
|
|
252
279
|
*
|
|
253
|
-
* See {@link https://github.com/
|
|
280
|
+
* See {@link https://github.com/kysely-org/kysely/blob/master/site/docs/recipes/0004-splitting-query-building-and-execution.md#execute-compiled-queries splitting build, compile and execute code recipe} for more information.
|
|
254
281
|
*/
|
|
255
282
|
executeQuery<R>(query: CompiledQuery<R> | Compilable<R>, queryId?: QueryId): Promise<QueryResult<R>>;
|
|
256
283
|
}
|
|
@@ -269,8 +296,11 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
269
296
|
* The returned {@link TransactionBuilder} can be used to configure the transaction. The
|
|
270
297
|
* {@link TransactionBuilder.execute} method can then be called to run the transaction.
|
|
271
298
|
* {@link TransactionBuilder.execute} takes a function that is run inside the
|
|
272
|
-
* transaction. If the function throws
|
|
273
|
-
* the
|
|
299
|
+
* transaction. If the function throws an exception,
|
|
300
|
+
* 1. the exception is caught,
|
|
301
|
+
* 2. the transaction is rolled back, and
|
|
302
|
+
* 3. the exception is thrown again.
|
|
303
|
+
* Otherwise the transaction is committed.
|
|
274
304
|
*
|
|
275
305
|
* The callback function passed to the {@link TransactionBuilder.execute | execute}
|
|
276
306
|
* method gets the transaction object as its only argument. The transaction is
|
|
@@ -281,9 +311,12 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
281
311
|
*
|
|
282
312
|
* <!-- siteExample("transactions", "Simple transaction", 10) -->
|
|
283
313
|
*
|
|
284
|
-
* This example inserts two rows in a transaction. If an
|
|
285
|
-
* the callback passed to the `execute` method,
|
|
286
|
-
*
|
|
314
|
+
* This example inserts two rows in a transaction. If an exception is thrown inside
|
|
315
|
+
* the callback passed to the `execute` method,
|
|
316
|
+
* 1. the exception is caught,
|
|
317
|
+
* 2. the transaction is rolled back, and
|
|
318
|
+
* 3. the exception is thrown again.
|
|
319
|
+
* Otherwise the transaction is committed.
|
|
287
320
|
*
|
|
288
321
|
* ```ts
|
|
289
322
|
* const catto = await db.transaction().execute(async (trx) => {
|
|
@@ -311,12 +344,18 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
311
344
|
* Setting the isolation level:
|
|
312
345
|
*
|
|
313
346
|
* ```ts
|
|
347
|
+
* import type { Kysely } from 'kysely'
|
|
348
|
+
*
|
|
314
349
|
* await db
|
|
315
350
|
* .transaction()
|
|
316
351
|
* .setIsolationLevel('serializable')
|
|
317
352
|
* .execute(async (trx) => {
|
|
318
353
|
* await doStuff(trx)
|
|
319
354
|
* })
|
|
355
|
+
*
|
|
356
|
+
* async function doStuff(kysely: typeof db) {
|
|
357
|
+
* // ...
|
|
358
|
+
* }
|
|
320
359
|
* ```
|
|
321
360
|
*/
|
|
322
361
|
transaction(): TransactionBuilder<DB>;
|
|
@@ -334,6 +373,10 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
334
373
|
* // the same connection.
|
|
335
374
|
* await doStuff(db)
|
|
336
375
|
* })
|
|
376
|
+
*
|
|
377
|
+
* async function doStuff(kysely: typeof db) {
|
|
378
|
+
* // ...
|
|
379
|
+
* }
|
|
337
380
|
* ```
|
|
338
381
|
*/
|
|
339
382
|
connection(): ConnectionBuilder<DB>;
|
|
@@ -366,7 +409,6 @@ export declare class Transaction<DB> extends Kysely<DB> {
|
|
|
366
409
|
*
|
|
367
410
|
* The following example adds and uses a temporary table:
|
|
368
411
|
*
|
|
369
|
-
* @example
|
|
370
412
|
* ```ts
|
|
371
413
|
* await db.schema
|
|
372
414
|
* .createTable('temp_table')
|
|
@@ -406,16 +448,32 @@ export interface KyselyConfig {
|
|
|
406
448
|
*
|
|
407
449
|
* ### Examples
|
|
408
450
|
*
|
|
451
|
+
* Setting up built-in logging for preferred log levels:
|
|
452
|
+
*
|
|
409
453
|
* ```ts
|
|
454
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
455
|
+
* import { Kysely, SqliteDialect } from 'kysely'
|
|
456
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
457
|
+
*
|
|
410
458
|
* const db = new Kysely<Database>({
|
|
411
|
-
* dialect: new
|
|
459
|
+
* dialect: new SqliteDialect({
|
|
460
|
+
* database: new Sqlite(':memory:'),
|
|
461
|
+
* }),
|
|
412
462
|
* log: ['query', 'error']
|
|
413
463
|
* })
|
|
414
464
|
* ```
|
|
415
465
|
*
|
|
466
|
+
* Setting up custom logging:
|
|
467
|
+
*
|
|
416
468
|
* ```ts
|
|
469
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
470
|
+
* import { Kysely, SqliteDialect } from 'kysely'
|
|
471
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
472
|
+
*
|
|
417
473
|
* const db = new Kysely<Database>({
|
|
418
|
-
* dialect: new
|
|
474
|
+
* dialect: new SqliteDialect({
|
|
475
|
+
* database: new Sqlite(':memory:'),
|
|
476
|
+
* }),
|
|
419
477
|
* log(event): void {
|
|
420
478
|
* if (event.level === 'query') {
|
|
421
479
|
* console.log(event.query.sql)
|