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
|
@@ -9,8 +9,26 @@ import { sql } from '../raw-builder/sql.js';
|
|
|
9
9
|
* The plugin can be installed like this:
|
|
10
10
|
*
|
|
11
11
|
* ```ts
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
|
|
13
|
+
* import * as Tarn from 'tarn'
|
|
14
|
+
* import * as Tedious from 'tedious'
|
|
15
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
16
|
+
*
|
|
17
|
+
* const db = new Kysely<Database>({
|
|
18
|
+
* dialect: new MssqlDialect({
|
|
19
|
+
* tarn: { options: { max: 10, min: 0 }, ...Tarn },
|
|
20
|
+
* tedious: {
|
|
21
|
+
* ...Tedious,
|
|
22
|
+
* connectionFactory: () => new Tedious.Connection({
|
|
23
|
+
* authentication: {
|
|
24
|
+
* options: { password: 'password', userName: 'sa' },
|
|
25
|
+
* type: 'default',
|
|
26
|
+
* },
|
|
27
|
+
* options: { database: 'test', port: 21433, trustServerCertificate: true },
|
|
28
|
+
* server: 'localhost',
|
|
29
|
+
* }),
|
|
30
|
+
* },
|
|
31
|
+
* }),
|
|
14
32
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
15
33
|
* })
|
|
16
34
|
* ```
|
|
@@ -18,6 +36,8 @@ import { sql } from '../raw-builder/sql.js';
|
|
|
18
36
|
* ### Examples
|
|
19
37
|
*
|
|
20
38
|
* ```ts
|
|
39
|
+
* import { jsonArrayFrom } from 'kysely/helpers/mssql'
|
|
40
|
+
*
|
|
21
41
|
* const result = await db
|
|
22
42
|
* .selectFrom('person')
|
|
23
43
|
* .select((eb) => [
|
|
@@ -27,14 +47,14 @@ import { sql } from '../raw-builder/sql.js';
|
|
|
27
47
|
* .select(['pet.id as pet_id', 'pet.name'])
|
|
28
48
|
* .whereRef('pet.owner_id', '=', 'person.id')
|
|
29
49
|
* .orderBy('pet.name')
|
|
30
|
-
* .
|
|
50
|
+
* .offset(0)
|
|
31
51
|
* ).as('pets')
|
|
32
52
|
* ])
|
|
33
53
|
* .execute()
|
|
34
54
|
*
|
|
35
|
-
* result[0]
|
|
36
|
-
* result[0]
|
|
37
|
-
* result[0]
|
|
55
|
+
* result[0]?.id
|
|
56
|
+
* result[0]?.pets[0]?.pet_id
|
|
57
|
+
* result[0]?.pets[0]?.name
|
|
38
58
|
* ```
|
|
39
59
|
*
|
|
40
60
|
* The generated SQL (MS SQL Server):
|
|
@@ -46,7 +66,7 @@ import { sql } from '../raw-builder/sql.js';
|
|
|
46
66
|
* from "pet"
|
|
47
67
|
* where "pet"."owner_id" = "person"."id"
|
|
48
68
|
* order by "pet"."name"
|
|
49
|
-
* offset
|
|
69
|
+
* offset @1 rows
|
|
50
70
|
* ) as "agg" for json path, include_null_values), '[]')
|
|
51
71
|
* ) as "pets"
|
|
52
72
|
* from "person"
|
|
@@ -66,8 +86,26 @@ export function jsonArrayFrom(expr) {
|
|
|
66
86
|
* The plugin can be installed like this:
|
|
67
87
|
*
|
|
68
88
|
* ```ts
|
|
69
|
-
*
|
|
70
|
-
*
|
|
89
|
+
* import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
|
|
90
|
+
* import * as Tarn from 'tarn'
|
|
91
|
+
* import * as Tedious from 'tedious'
|
|
92
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
93
|
+
*
|
|
94
|
+
* const db = new Kysely<Database>({
|
|
95
|
+
* dialect: new MssqlDialect({
|
|
96
|
+
* tarn: { options: { max: 10, min: 0 }, ...Tarn },
|
|
97
|
+
* tedious: {
|
|
98
|
+
* ...Tedious,
|
|
99
|
+
* connectionFactory: () => new Tedious.Connection({
|
|
100
|
+
* authentication: {
|
|
101
|
+
* options: { password: 'password', userName: 'sa' },
|
|
102
|
+
* type: 'default',
|
|
103
|
+
* },
|
|
104
|
+
* options: { database: 'test', port: 21433, trustServerCertificate: true },
|
|
105
|
+
* server: 'localhost',
|
|
106
|
+
* }),
|
|
107
|
+
* },
|
|
108
|
+
* }),
|
|
71
109
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
72
110
|
* })
|
|
73
111
|
* ```
|
|
@@ -75,6 +113,8 @@ export function jsonArrayFrom(expr) {
|
|
|
75
113
|
* ### Examples
|
|
76
114
|
*
|
|
77
115
|
* ```ts
|
|
116
|
+
* import { jsonObjectFrom } from 'kysely/helpers/mssql'
|
|
117
|
+
*
|
|
78
118
|
* const result = await db
|
|
79
119
|
* .selectFrom('person')
|
|
80
120
|
* .select((eb) => [
|
|
@@ -88,9 +128,9 @@ export function jsonArrayFrom(expr) {
|
|
|
88
128
|
* ])
|
|
89
129
|
* .execute()
|
|
90
130
|
*
|
|
91
|
-
* result[0]
|
|
92
|
-
* result[0]
|
|
93
|
-
* result[0]
|
|
131
|
+
* result[0]?.id
|
|
132
|
+
* result[0]?.favorite_pet?.pet_id
|
|
133
|
+
* result[0]?.favorite_pet?.name
|
|
94
134
|
* ```
|
|
95
135
|
*
|
|
96
136
|
* The generated SQL (MS SQL Server):
|
|
@@ -119,8 +159,26 @@ export function jsonObjectFrom(expr) {
|
|
|
119
159
|
* The plugin can be installed like this:
|
|
120
160
|
*
|
|
121
161
|
* ```ts
|
|
122
|
-
*
|
|
123
|
-
*
|
|
162
|
+
* import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
|
|
163
|
+
* import * as Tarn from 'tarn'
|
|
164
|
+
* import * as Tedious from 'tedious'
|
|
165
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
166
|
+
*
|
|
167
|
+
* const db = new Kysely<Database>({
|
|
168
|
+
* dialect: new MssqlDialect({
|
|
169
|
+
* tarn: { options: { max: 10, min: 0 }, ...Tarn },
|
|
170
|
+
* tedious: {
|
|
171
|
+
* ...Tedious,
|
|
172
|
+
* connectionFactory: () => new Tedious.Connection({
|
|
173
|
+
* authentication: {
|
|
174
|
+
* options: { password: 'password', userName: 'sa' },
|
|
175
|
+
* type: 'default',
|
|
176
|
+
* },
|
|
177
|
+
* options: { database: 'test', port: 21433, trustServerCertificate: true },
|
|
178
|
+
* server: 'localhost',
|
|
179
|
+
* }),
|
|
180
|
+
* },
|
|
181
|
+
* }),
|
|
124
182
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
125
183
|
* })
|
|
126
184
|
* ```
|
|
@@ -128,6 +186,8 @@ export function jsonObjectFrom(expr) {
|
|
|
128
186
|
* ### Examples
|
|
129
187
|
*
|
|
130
188
|
* ```ts
|
|
189
|
+
* import { jsonBuildObject } from 'kysely/helpers/mssql'
|
|
190
|
+
*
|
|
131
191
|
* const result = await db
|
|
132
192
|
* .selectFrom('person')
|
|
133
193
|
* .select((eb) => [
|
|
@@ -6,13 +6,15 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
6
6
|
* A MySQL helper for aggregating a subquery into a JSON array.
|
|
7
7
|
*
|
|
8
8
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
9
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
9
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
10
10
|
* may not parse the nested JSON into arrays. In these cases you can use the built in
|
|
11
11
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
12
12
|
*
|
|
13
13
|
* ### Examples
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
+
* import { jsonArrayFrom } from 'kysely/helpers/mysql'
|
|
17
|
+
*
|
|
16
18
|
* const result = await db
|
|
17
19
|
* .selectFrom('person')
|
|
18
20
|
* .select((eb) => [
|
|
@@ -26,9 +28,9 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
26
28
|
* ])
|
|
27
29
|
* .execute()
|
|
28
30
|
*
|
|
29
|
-
* result[0]
|
|
30
|
-
* result[0]
|
|
31
|
-
* result[0]
|
|
31
|
+
* result[0]?.id
|
|
32
|
+
* result[0]?.pets[0]?.pet_id
|
|
33
|
+
* result[0]?.pets[0]?.name
|
|
32
34
|
* ```
|
|
33
35
|
*
|
|
34
36
|
* The generated SQL (MySQL):
|
|
@@ -55,13 +57,15 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
55
57
|
* The subquery must only return one row.
|
|
56
58
|
*
|
|
57
59
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
58
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
60
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
59
61
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
60
62
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
61
63
|
*
|
|
62
64
|
* ### Examples
|
|
63
65
|
*
|
|
64
66
|
* ```ts
|
|
67
|
+
* import { jsonObjectFrom } from 'kysely/helpers/mysql'
|
|
68
|
+
*
|
|
65
69
|
* const result = await db
|
|
66
70
|
* .selectFrom('person')
|
|
67
71
|
* .select((eb) => [
|
|
@@ -75,9 +79,9 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
75
79
|
* ])
|
|
76
80
|
* .execute()
|
|
77
81
|
*
|
|
78
|
-
* result[0]
|
|
79
|
-
* result[0]
|
|
80
|
-
* result[0]
|
|
82
|
+
* result[0]?.id
|
|
83
|
+
* result[0]?.favorite_pet?.pet_id
|
|
84
|
+
* result[0]?.favorite_pet?.name
|
|
81
85
|
* ```
|
|
82
86
|
*
|
|
83
87
|
* The generated SQL (MySQL):
|
|
@@ -102,7 +106,7 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
102
106
|
* The MySQL `json_object` function.
|
|
103
107
|
*
|
|
104
108
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
105
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
109
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
106
110
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
107
111
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
108
112
|
*
|
|
@@ -121,10 +125,10 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
121
125
|
* ])
|
|
122
126
|
* .execute()
|
|
123
127
|
*
|
|
124
|
-
* result[0]
|
|
125
|
-
* result[0]
|
|
126
|
-
* result[0]
|
|
127
|
-
* result[0]
|
|
128
|
+
* result[0]?.id
|
|
129
|
+
* result[0]?.name.first
|
|
130
|
+
* result[0]?.name.last
|
|
131
|
+
* result[0]?.name.full
|
|
128
132
|
* ```
|
|
129
133
|
*
|
|
130
134
|
* The generated SQL (MySQL):
|
|
@@ -5,13 +5,15 @@ import { getJsonObjectArgs } from '../util/json-object-args.js';
|
|
|
5
5
|
* A MySQL helper for aggregating a subquery into a JSON array.
|
|
6
6
|
*
|
|
7
7
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
8
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
8
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
9
9
|
* may not parse the nested JSON into arrays. In these cases you can use the built in
|
|
10
10
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
11
11
|
*
|
|
12
12
|
* ### Examples
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
+
* import { jsonArrayFrom } from 'kysely/helpers/mysql'
|
|
16
|
+
*
|
|
15
17
|
* const result = await db
|
|
16
18
|
* .selectFrom('person')
|
|
17
19
|
* .select((eb) => [
|
|
@@ -25,9 +27,9 @@ import { getJsonObjectArgs } from '../util/json-object-args.js';
|
|
|
25
27
|
* ])
|
|
26
28
|
* .execute()
|
|
27
29
|
*
|
|
28
|
-
* result[0]
|
|
29
|
-
* result[0]
|
|
30
|
-
* result[0]
|
|
30
|
+
* result[0]?.id
|
|
31
|
+
* result[0]?.pets[0]?.pet_id
|
|
32
|
+
* result[0]?.pets[0]?.name
|
|
31
33
|
* ```
|
|
32
34
|
*
|
|
33
35
|
* The generated SQL (MySQL):
|
|
@@ -56,13 +58,15 @@ export function jsonArrayFrom(expr) {
|
|
|
56
58
|
* The subquery must only return one row.
|
|
57
59
|
*
|
|
58
60
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
59
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
61
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
60
62
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
61
63
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
62
64
|
*
|
|
63
65
|
* ### Examples
|
|
64
66
|
*
|
|
65
67
|
* ```ts
|
|
68
|
+
* import { jsonObjectFrom } from 'kysely/helpers/mysql'
|
|
69
|
+
*
|
|
66
70
|
* const result = await db
|
|
67
71
|
* .selectFrom('person')
|
|
68
72
|
* .select((eb) => [
|
|
@@ -76,9 +80,9 @@ export function jsonArrayFrom(expr) {
|
|
|
76
80
|
* ])
|
|
77
81
|
* .execute()
|
|
78
82
|
*
|
|
79
|
-
* result[0]
|
|
80
|
-
* result[0]
|
|
81
|
-
* result[0]
|
|
83
|
+
* result[0]?.id
|
|
84
|
+
* result[0]?.favorite_pet?.pet_id
|
|
85
|
+
* result[0]?.favorite_pet?.name
|
|
82
86
|
* ```
|
|
83
87
|
*
|
|
84
88
|
* The generated SQL (MySQL):
|
|
@@ -105,7 +109,7 @@ export function jsonObjectFrom(expr) {
|
|
|
105
109
|
* The MySQL `json_object` function.
|
|
106
110
|
*
|
|
107
111
|
* NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
|
|
108
|
-
* While the produced SQL is compatible with all MySQL databases, some
|
|
112
|
+
* While the produced SQL is compatible with all MySQL databases, some third-party dialects
|
|
109
113
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
110
114
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
111
115
|
*
|
|
@@ -124,10 +128,10 @@ export function jsonObjectFrom(expr) {
|
|
|
124
128
|
* ])
|
|
125
129
|
* .execute()
|
|
126
130
|
*
|
|
127
|
-
* result[0]
|
|
128
|
-
* result[0]
|
|
129
|
-
* result[0]
|
|
130
|
-
* result[0]
|
|
131
|
+
* result[0]?.id
|
|
132
|
+
* result[0]?.name.first
|
|
133
|
+
* result[0]?.name.last
|
|
134
|
+
* result[0]?.name.full
|
|
131
135
|
* ```
|
|
132
136
|
*
|
|
133
137
|
* The generated SQL (MySQL):
|
|
@@ -15,7 +15,7 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
15
15
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
16
16
|
* `jsonArrayFrom`, are not guaranteed to work with third party dialects. In order for
|
|
17
17
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
18
|
-
*
|
|
18
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
19
19
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
20
20
|
* to parse the results.
|
|
21
21
|
*
|
|
@@ -65,9 +65,9 @@ export declare function jsonArrayFrom<O>(expr: Expression<O>): RawBuilder<Simpli
|
|
|
65
65
|
* use the `jsonObjectFrom` helper to fetch person's favorite pet along with the person's id.
|
|
66
66
|
*
|
|
67
67
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
68
|
-
* `jsonObjectFrom`, are not guaranteed to work with
|
|
68
|
+
* `jsonObjectFrom`, are not guaranteed to work with third-party dialects. In order for
|
|
69
69
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
70
|
-
*
|
|
70
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
71
71
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
72
72
|
* to parse the results.
|
|
73
73
|
*
|
|
@@ -107,13 +107,16 @@ export declare function jsonObjectFrom<O>(expr: Expression<O>): RawBuilder<Simpl
|
|
|
107
107
|
* The PostgreSQL `json_build_object` function.
|
|
108
108
|
*
|
|
109
109
|
* NOTE: This helper is only guaranteed to fully work with the built-in `PostgresDialect`.
|
|
110
|
-
* While the produced SQL is compatible with all PostgreSQL databases, some
|
|
110
|
+
* While the produced SQL is compatible with all PostgreSQL databases, some third-party dialects
|
|
111
111
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
112
112
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
113
113
|
*
|
|
114
114
|
* ### Examples
|
|
115
115
|
*
|
|
116
116
|
* ```ts
|
|
117
|
+
* import { sql } from 'kysely'
|
|
118
|
+
* import { jsonBuildObject } from 'kysely/helpers/postgres'
|
|
119
|
+
*
|
|
117
120
|
* const result = await db
|
|
118
121
|
* .selectFrom('person')
|
|
119
122
|
* .select((eb) => [
|
|
@@ -126,10 +129,10 @@ export declare function jsonObjectFrom<O>(expr: Expression<O>): RawBuilder<Simpl
|
|
|
126
129
|
* ])
|
|
127
130
|
* .execute()
|
|
128
131
|
*
|
|
129
|
-
* result[0]
|
|
130
|
-
* result[0]
|
|
131
|
-
* result[0]
|
|
132
|
-
* result[0]
|
|
132
|
+
* result[0]?.id
|
|
133
|
+
* result[0]?.name.first
|
|
134
|
+
* result[0]?.name.last
|
|
135
|
+
* result[0]?.name.full
|
|
133
136
|
* ```
|
|
134
137
|
*
|
|
135
138
|
* The generated SQL (PostgreSQL):
|
|
@@ -14,7 +14,7 @@ import { sql } from '../raw-builder/sql.js';
|
|
|
14
14
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
15
15
|
* `jsonArrayFrom`, are not guaranteed to work with third party dialects. In order for
|
|
16
16
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
17
|
-
*
|
|
17
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
18
18
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
19
19
|
* to parse the results.
|
|
20
20
|
*
|
|
@@ -66,9 +66,9 @@ export function jsonArrayFrom(expr) {
|
|
|
66
66
|
* use the `jsonObjectFrom` helper to fetch person's favorite pet along with the person's id.
|
|
67
67
|
*
|
|
68
68
|
* Please keep in mind that the helpers under the `kysely/helpers` folder, including
|
|
69
|
-
* `jsonObjectFrom`, are not guaranteed to work with
|
|
69
|
+
* `jsonObjectFrom`, are not guaranteed to work with third-party dialects. In order for
|
|
70
70
|
* them to work, the dialect must automatically parse the `json` data type into
|
|
71
|
-
*
|
|
71
|
+
* JavaScript JSON values like objects and arrays. Some dialects might simply return
|
|
72
72
|
* the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
|
|
73
73
|
* to parse the results.
|
|
74
74
|
*
|
|
@@ -110,13 +110,16 @@ export function jsonObjectFrom(expr) {
|
|
|
110
110
|
* The PostgreSQL `json_build_object` function.
|
|
111
111
|
*
|
|
112
112
|
* NOTE: This helper is only guaranteed to fully work with the built-in `PostgresDialect`.
|
|
113
|
-
* While the produced SQL is compatible with all PostgreSQL databases, some
|
|
113
|
+
* While the produced SQL is compatible with all PostgreSQL databases, some third-party dialects
|
|
114
114
|
* may not parse the nested JSON into objects. In these cases you can use the built in
|
|
115
115
|
* `ParseJSONResultsPlugin` to parse the results.
|
|
116
116
|
*
|
|
117
117
|
* ### Examples
|
|
118
118
|
*
|
|
119
119
|
* ```ts
|
|
120
|
+
* import { sql } from 'kysely'
|
|
121
|
+
* import { jsonBuildObject } from 'kysely/helpers/postgres'
|
|
122
|
+
*
|
|
120
123
|
* const result = await db
|
|
121
124
|
* .selectFrom('person')
|
|
122
125
|
* .select((eb) => [
|
|
@@ -129,10 +132,10 @@ export function jsonObjectFrom(expr) {
|
|
|
129
132
|
* ])
|
|
130
133
|
* .execute()
|
|
131
134
|
*
|
|
132
|
-
* result[0]
|
|
133
|
-
* result[0]
|
|
134
|
-
* result[0]
|
|
135
|
-
* result[0]
|
|
135
|
+
* result[0]?.id
|
|
136
|
+
* result[0]?.name.first
|
|
137
|
+
* result[0]?.name.last
|
|
138
|
+
* result[0]?.name.full
|
|
136
139
|
* ```
|
|
137
140
|
*
|
|
138
141
|
* The generated SQL (PostgreSQL):
|
|
@@ -11,8 +11,14 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
11
11
|
* The plugin can be installed like this:
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
15
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
16
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
17
|
+
*
|
|
18
|
+
* const db = new Kysely<Database>({
|
|
19
|
+
* dialect: new SqliteDialect({
|
|
20
|
+
* database: new Sqlite(':memory:')
|
|
21
|
+
* }),
|
|
16
22
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
17
23
|
* })
|
|
18
24
|
* ```
|
|
@@ -20,6 +26,8 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
20
26
|
* ### Examples
|
|
21
27
|
*
|
|
22
28
|
* ```ts
|
|
29
|
+
* import { jsonArrayFrom } from 'kysely/helpers/sqlite'
|
|
30
|
+
*
|
|
23
31
|
* const result = await db
|
|
24
32
|
* .selectFrom('person')
|
|
25
33
|
* .select((eb) => [
|
|
@@ -33,9 +41,9 @@ import { Simplify } from '../util/type-utils.js';
|
|
|
33
41
|
* ])
|
|
34
42
|
* .execute()
|
|
35
43
|
*
|
|
36
|
-
* result[0]
|
|
37
|
-
* result[0]
|
|
38
|
-
* result[0]
|
|
44
|
+
* result[0]?.id
|
|
45
|
+
* result[0]?.pets[0].pet_id
|
|
46
|
+
* result[0]?.pets[0].name
|
|
39
47
|
* ```
|
|
40
48
|
*
|
|
41
49
|
* The generated SQL (SQLite):
|
|
@@ -67,8 +75,14 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
67
75
|
* The plugin can be installed like this:
|
|
68
76
|
*
|
|
69
77
|
* ```ts
|
|
70
|
-
*
|
|
71
|
-
*
|
|
78
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
79
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
80
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
81
|
+
*
|
|
82
|
+
* const db = new Kysely<Database>({
|
|
83
|
+
* dialect: new SqliteDialect({
|
|
84
|
+
* database: new Sqlite(':memory:')
|
|
85
|
+
* }),
|
|
72
86
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
73
87
|
* })
|
|
74
88
|
* ```
|
|
@@ -76,6 +90,8 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
76
90
|
* ### Examples
|
|
77
91
|
*
|
|
78
92
|
* ```ts
|
|
93
|
+
* import { jsonObjectFrom } from 'kysely/helpers/sqlite'
|
|
94
|
+
*
|
|
79
95
|
* const result = await db
|
|
80
96
|
* .selectFrom('person')
|
|
81
97
|
* .select((eb) => [
|
|
@@ -89,9 +105,9 @@ export declare function jsonArrayFrom<O>(expr: SelectQueryBuilderExpression<O>):
|
|
|
89
105
|
* ])
|
|
90
106
|
* .execute()
|
|
91
107
|
*
|
|
92
|
-
* result[0]
|
|
93
|
-
* result[0]
|
|
94
|
-
* result[0]
|
|
108
|
+
* result[0]?.id
|
|
109
|
+
* result[0]?.favorite_pet?.pet_id
|
|
110
|
+
* result[0]?.favorite_pet?.name
|
|
95
111
|
* ```
|
|
96
112
|
*
|
|
97
113
|
* The generated SQL (SQLite):
|
|
@@ -121,8 +137,14 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
121
137
|
* The plugin can be installed like this:
|
|
122
138
|
*
|
|
123
139
|
* ```ts
|
|
124
|
-
*
|
|
125
|
-
*
|
|
140
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
141
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
142
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
143
|
+
*
|
|
144
|
+
* const db = new Kysely<Database>({
|
|
145
|
+
* dialect: new SqliteDialect({
|
|
146
|
+
* database: new Sqlite(':memory:')
|
|
147
|
+
* }),
|
|
126
148
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
127
149
|
* })
|
|
128
150
|
* ```
|
|
@@ -130,6 +152,9 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
130
152
|
* ### Examples
|
|
131
153
|
*
|
|
132
154
|
* ```ts
|
|
155
|
+
* import { sql } from 'kysely'
|
|
156
|
+
* import { jsonBuildObject } from 'kysely/helpers/sqlite'
|
|
157
|
+
*
|
|
133
158
|
* const result = await db
|
|
134
159
|
* .selectFrom('person')
|
|
135
160
|
* .select((eb) => [
|
|
@@ -142,10 +167,10 @@ export declare function jsonObjectFrom<O>(expr: SelectQueryBuilderExpression<O>)
|
|
|
142
167
|
* ])
|
|
143
168
|
* .execute()
|
|
144
169
|
*
|
|
145
|
-
* result[0]
|
|
146
|
-
* result[0]
|
|
147
|
-
* result[0]
|
|
148
|
-
* result[0]
|
|
170
|
+
* result[0]?.id
|
|
171
|
+
* result[0]?.name.first
|
|
172
|
+
* result[0]?.name.last
|
|
173
|
+
* result[0]?.name.full
|
|
149
174
|
* ```
|
|
150
175
|
*
|
|
151
176
|
* The generated SQL (SQLite):
|
|
@@ -10,8 +10,14 @@ import { getJsonObjectArgs } from '../util/json-object-args.js';
|
|
|
10
10
|
* The plugin can be installed like this:
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
14
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
15
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
16
|
+
*
|
|
17
|
+
* const db = new Kysely<Database>({
|
|
18
|
+
* dialect: new SqliteDialect({
|
|
19
|
+
* database: new Sqlite(':memory:')
|
|
20
|
+
* }),
|
|
15
21
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
16
22
|
* })
|
|
17
23
|
* ```
|
|
@@ -19,6 +25,8 @@ import { getJsonObjectArgs } from '../util/json-object-args.js';
|
|
|
19
25
|
* ### Examples
|
|
20
26
|
*
|
|
21
27
|
* ```ts
|
|
28
|
+
* import { jsonArrayFrom } from 'kysely/helpers/sqlite'
|
|
29
|
+
*
|
|
22
30
|
* const result = await db
|
|
23
31
|
* .selectFrom('person')
|
|
24
32
|
* .select((eb) => [
|
|
@@ -32,9 +40,9 @@ import { getJsonObjectArgs } from '../util/json-object-args.js';
|
|
|
32
40
|
* ])
|
|
33
41
|
* .execute()
|
|
34
42
|
*
|
|
35
|
-
* result[0]
|
|
36
|
-
* result[0]
|
|
37
|
-
* result[0]
|
|
43
|
+
* result[0]?.id
|
|
44
|
+
* result[0]?.pets[0].pet_id
|
|
45
|
+
* result[0]?.pets[0].name
|
|
38
46
|
* ```
|
|
39
47
|
*
|
|
40
48
|
* The generated SQL (SQLite):
|
|
@@ -68,8 +76,14 @@ export function jsonArrayFrom(expr) {
|
|
|
68
76
|
* The plugin can be installed like this:
|
|
69
77
|
*
|
|
70
78
|
* ```ts
|
|
71
|
-
*
|
|
72
|
-
*
|
|
79
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
80
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
81
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
82
|
+
*
|
|
83
|
+
* const db = new Kysely<Database>({
|
|
84
|
+
* dialect: new SqliteDialect({
|
|
85
|
+
* database: new Sqlite(':memory:')
|
|
86
|
+
* }),
|
|
73
87
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
74
88
|
* })
|
|
75
89
|
* ```
|
|
@@ -77,6 +91,8 @@ export function jsonArrayFrom(expr) {
|
|
|
77
91
|
* ### Examples
|
|
78
92
|
*
|
|
79
93
|
* ```ts
|
|
94
|
+
* import { jsonObjectFrom } from 'kysely/helpers/sqlite'
|
|
95
|
+
*
|
|
80
96
|
* const result = await db
|
|
81
97
|
* .selectFrom('person')
|
|
82
98
|
* .select((eb) => [
|
|
@@ -90,9 +106,9 @@ export function jsonArrayFrom(expr) {
|
|
|
90
106
|
* ])
|
|
91
107
|
* .execute()
|
|
92
108
|
*
|
|
93
|
-
* result[0]
|
|
94
|
-
* result[0]
|
|
95
|
-
* result[0]
|
|
109
|
+
* result[0]?.id
|
|
110
|
+
* result[0]?.favorite_pet?.pet_id
|
|
111
|
+
* result[0]?.favorite_pet?.name
|
|
96
112
|
* ```
|
|
97
113
|
*
|
|
98
114
|
* The generated SQL (SQLite):
|
|
@@ -124,8 +140,14 @@ export function jsonObjectFrom(expr) {
|
|
|
124
140
|
* The plugin can be installed like this:
|
|
125
141
|
*
|
|
126
142
|
* ```ts
|
|
127
|
-
*
|
|
128
|
-
*
|
|
143
|
+
* import * as Sqlite from 'better-sqlite3'
|
|
144
|
+
* import { Kysely, ParseJSONResultsPlugin, SqliteDialect } from 'kysely'
|
|
145
|
+
* import type { Database } from 'type-editor' // imaginary module
|
|
146
|
+
*
|
|
147
|
+
* const db = new Kysely<Database>({
|
|
148
|
+
* dialect: new SqliteDialect({
|
|
149
|
+
* database: new Sqlite(':memory:')
|
|
150
|
+
* }),
|
|
129
151
|
* plugins: [new ParseJSONResultsPlugin()]
|
|
130
152
|
* })
|
|
131
153
|
* ```
|
|
@@ -133,6 +155,9 @@ export function jsonObjectFrom(expr) {
|
|
|
133
155
|
* ### Examples
|
|
134
156
|
*
|
|
135
157
|
* ```ts
|
|
158
|
+
* import { sql } from 'kysely'
|
|
159
|
+
* import { jsonBuildObject } from 'kysely/helpers/sqlite'
|
|
160
|
+
*
|
|
136
161
|
* const result = await db
|
|
137
162
|
* .selectFrom('person')
|
|
138
163
|
* .select((eb) => [
|
|
@@ -145,10 +170,10 @@ export function jsonObjectFrom(expr) {
|
|
|
145
170
|
* ])
|
|
146
171
|
* .execute()
|
|
147
172
|
*
|
|
148
|
-
* result[0]
|
|
149
|
-
* result[0]
|
|
150
|
-
* result[0]
|
|
151
|
-
* result[0]
|
|
173
|
+
* result[0]?.id
|
|
174
|
+
* result[0]?.name.first
|
|
175
|
+
* result[0]?.name.last
|
|
176
|
+
* result[0]?.name.full
|
|
152
177
|
* ```
|
|
153
178
|
*
|
|
154
179
|
* The generated SQL (SQLite):
|