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.
Files changed (301) hide show
  1. package/.renovaterc.json +3 -0
  2. package/CONTRIBUTING.md +2 -2
  3. package/README.md +7 -7
  4. package/deno.check.d.ts +86 -0
  5. package/deno.check.json +21 -0
  6. package/dist/cjs/dialect/dialect-adapter-base.d.ts +13 -3
  7. package/dist/cjs/dialect/dialect-adapter-base.js +4 -1
  8. package/dist/cjs/dialect/dialect-adapter.d.ts +16 -2
  9. package/dist/cjs/dialect/mssql/mssql-adapter.d.ts +12 -7
  10. package/dist/cjs/dialect/mssql/mssql-adapter.js +2 -4
  11. package/dist/cjs/dialect/mssql/mssql-dialect-config.d.ts +83 -55
  12. package/dist/cjs/dialect/mssql/mssql-driver.d.ts +1 -0
  13. package/dist/cjs/dialect/mssql/mssql-driver.js +114 -48
  14. package/dist/cjs/dialect/mysql/mysql-adapter.d.ts +11 -2
  15. package/dist/cjs/dialect/mysql/mysql-dialect-config.d.ts +4 -0
  16. package/dist/cjs/dialect/mysql/mysql-driver.js +3 -0
  17. package/dist/cjs/dialect/postgres/postgres-adapter.d.ts +11 -2
  18. package/dist/cjs/dialect/postgres/postgres-dialect-config.d.ts +10 -3
  19. package/dist/cjs/dialect/postgres/postgres-driver.js +3 -0
  20. package/dist/cjs/dialect/postgres/postgres-introspector.js +5 -1
  21. package/dist/cjs/dialect/sqlite/sqlite-adapter.d.ts +11 -2
  22. package/dist/cjs/driver/database-connection.d.ts +3 -1
  23. package/dist/cjs/driver/dummy-driver.d.ts +13 -12
  24. package/dist/cjs/driver/dummy-driver.js +13 -12
  25. package/dist/cjs/dynamic/dynamic-reference-builder.js +2 -2
  26. package/dist/cjs/dynamic/dynamic.d.ts +7 -7
  27. package/dist/cjs/dynamic/dynamic.js +7 -7
  28. package/dist/cjs/expression/expression-builder.d.ts +153 -62
  29. package/dist/cjs/expression/expression-builder.js +2 -3
  30. package/dist/cjs/expression/expression-wrapper.d.ts +92 -23
  31. package/dist/cjs/expression/expression.d.ts +40 -5
  32. package/dist/cjs/expression/expression.js +2 -3
  33. package/dist/cjs/helpers/mssql.d.ts +74 -14
  34. package/dist/cjs/helpers/mssql.js +77 -18
  35. package/dist/cjs/helpers/mysql.d.ts +17 -13
  36. package/dist/cjs/helpers/mysql.js +20 -17
  37. package/dist/cjs/helpers/postgres.d.ts +11 -8
  38. package/dist/cjs/helpers/postgres.js +14 -12
  39. package/dist/cjs/helpers/sqlite.d.ts +41 -16
  40. package/dist/cjs/helpers/sqlite.js +44 -20
  41. package/dist/cjs/index.d.ts +28 -21
  42. package/dist/cjs/index.js +28 -21
  43. package/dist/cjs/kysely.d.ts +100 -42
  44. package/dist/cjs/kysely.js +63 -39
  45. package/dist/cjs/migration/file-migration-provider.d.ts +2 -2
  46. package/dist/cjs/migration/file-migration-provider.js +2 -2
  47. package/dist/cjs/migration/migrator.d.ts +82 -14
  48. package/dist/cjs/migration/migrator.js +82 -14
  49. package/dist/cjs/operation-node/aggregate-function-node.d.ts +4 -0
  50. package/dist/cjs/operation-node/aggregate-function-node.js +9 -0
  51. package/dist/cjs/operation-node/alter-column-node.d.ts +1 -1
  52. package/dist/cjs/operation-node/case-node.d.ts +1 -1
  53. package/dist/cjs/operation-node/column-definition-node.d.ts +1 -0
  54. package/dist/cjs/operation-node/data-type-node.d.ts +2 -2
  55. package/dist/cjs/operation-node/data-type-node.js +17 -3
  56. package/dist/cjs/operation-node/delete-query-node.d.ts +3 -0
  57. package/dist/cjs/operation-node/foreign-key-constraint-node.d.ts +4 -4
  58. package/dist/cjs/operation-node/having-node.d.ts +1 -1
  59. package/dist/cjs/operation-node/insert-query-node.d.ts +3 -0
  60. package/dist/cjs/operation-node/merge-query-node.d.ts +3 -0
  61. package/dist/cjs/operation-node/on-node.d.ts +1 -1
  62. package/dist/cjs/operation-node/operation-node-source.js +1 -2
  63. package/dist/cjs/operation-node/operation-node-transformer.d.ts +11 -3
  64. package/dist/cjs/operation-node/operation-node-transformer.js +26 -3
  65. package/dist/cjs/operation-node/operation-node-visitor.d.ts +2 -0
  66. package/dist/cjs/operation-node/operation-node-visitor.js +1 -0
  67. package/dist/cjs/operation-node/operation-node.d.ts +1 -1
  68. package/dist/cjs/operation-node/operator-node.d.ts +3 -3
  69. package/dist/cjs/operation-node/operator-node.js +8 -6
  70. package/dist/cjs/operation-node/output-node.d.ts +13 -0
  71. package/dist/cjs/operation-node/output-node.js +26 -0
  72. package/dist/cjs/operation-node/query-node.d.ts +15 -6
  73. package/dist/cjs/operation-node/query-node.js +17 -0
  74. package/dist/cjs/operation-node/select-query-node.d.ts +1 -1
  75. package/dist/cjs/operation-node/select-query-node.js +6 -8
  76. package/dist/cjs/operation-node/update-query-node.d.ts +3 -0
  77. package/dist/cjs/operation-node/where-node.d.ts +1 -1
  78. package/dist/cjs/parser/binary-operation-parser.js +5 -6
  79. package/dist/cjs/parser/data-type-parser.js +1 -2
  80. package/dist/cjs/parser/default-value-parser.js +1 -2
  81. package/dist/cjs/parser/expression-parser.js +3 -4
  82. package/dist/cjs/parser/fetch-parser.js +1 -2
  83. package/dist/cjs/parser/group-by-parser.js +1 -2
  84. package/dist/cjs/parser/identifier-parser.js +1 -2
  85. package/dist/cjs/parser/insert-values-parser.js +1 -2
  86. package/dist/cjs/parser/join-parser.js +1 -2
  87. package/dist/cjs/parser/merge-parser.js +2 -3
  88. package/dist/cjs/parser/on-commit-action-parse.js +1 -2
  89. package/dist/cjs/parser/on-modify-action-parser.js +1 -2
  90. package/dist/cjs/parser/order-by-parser.js +3 -4
  91. package/dist/cjs/parser/parse-utils.js +4 -5
  92. package/dist/cjs/parser/partition-by-parser.js +1 -2
  93. package/dist/cjs/parser/reference-parser.js +8 -9
  94. package/dist/cjs/parser/returning-parser.d.ts +4 -3
  95. package/dist/cjs/parser/select-parser.js +2 -3
  96. package/dist/cjs/parser/set-operation-parser.js +1 -2
  97. package/dist/cjs/parser/table-parser.js +4 -5
  98. package/dist/cjs/parser/top-parser.js +1 -2
  99. package/dist/cjs/parser/unary-operation-parser.js +3 -4
  100. package/dist/cjs/parser/update-set-parser.js +2 -3
  101. package/dist/cjs/parser/value-parser.js +4 -5
  102. package/dist/cjs/parser/with-parser.js +1 -2
  103. package/dist/cjs/plugin/camel-case/camel-case-plugin.d.ts +54 -27
  104. package/dist/cjs/plugin/camel-case/camel-case-plugin.js +26 -21
  105. package/dist/cjs/plugin/camel-case/camel-case.js +2 -3
  106. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
  107. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  108. package/dist/cjs/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
  109. package/dist/cjs/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
  110. package/dist/cjs/plugin/kysely-plugin.d.ts +28 -6
  111. package/dist/cjs/plugin/noop-plugin.d.ts +28 -6
  112. package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
  113. package/dist/cjs/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
  114. package/dist/cjs/plugin/with-schema/with-schema-plugin.d.ts +28 -6
  115. package/dist/cjs/query-builder/aggregate-function-builder.d.ts +43 -1
  116. package/dist/cjs/query-builder/aggregate-function-builder.js +30 -0
  117. package/dist/cjs/query-builder/delete-query-builder.d.ts +219 -43
  118. package/dist/cjs/query-builder/delete-query-builder.js +95 -31
  119. package/dist/cjs/query-builder/function-module.d.ts +40 -93
  120. package/dist/cjs/query-builder/function-module.js +1 -2
  121. package/dist/cjs/query-builder/insert-query-builder.d.ts +326 -67
  122. package/dist/cjs/query-builder/insert-query-builder.js +212 -61
  123. package/dist/cjs/query-builder/insert-result.d.ts +10 -5
  124. package/dist/cjs/query-builder/insert-result.js +10 -5
  125. package/dist/cjs/query-builder/json-path-builder.d.ts +33 -9
  126. package/dist/cjs/query-builder/json-path-builder.js +8 -5
  127. package/dist/cjs/query-builder/merge-query-builder.d.ts +312 -10
  128. package/dist/cjs/query-builder/merge-query-builder.js +98 -7
  129. package/dist/cjs/query-builder/no-result-error.js +2 -2
  130. package/dist/cjs/query-builder/on-conflict-builder.d.ts +53 -20
  131. package/dist/cjs/query-builder/on-conflict-builder.js +41 -16
  132. package/dist/cjs/query-builder/output-interface.d.ts +138 -0
  133. package/dist/cjs/query-builder/output-interface.js +2 -0
  134. package/dist/cjs/query-builder/returning-interface.d.ts +7 -5
  135. package/dist/cjs/query-builder/select-query-builder-expression.d.ts +8 -0
  136. package/dist/cjs/query-builder/select-query-builder.d.ts +370 -73
  137. package/dist/cjs/query-builder/select-query-builder.js +14 -9
  138. package/dist/cjs/query-builder/update-query-builder.d.ts +225 -31
  139. package/dist/cjs/query-builder/update-query-builder.js +96 -17
  140. package/dist/cjs/query-builder/update-result.d.ts +9 -0
  141. package/dist/cjs/query-builder/update-result.js +9 -0
  142. package/dist/cjs/query-builder/where-interface.d.ts +6 -2
  143. package/dist/cjs/query-compiler/default-query-compiler.d.ts +2 -0
  144. package/dist/cjs/query-compiler/default-query-compiler.js +45 -1
  145. package/dist/cjs/query-creator.d.ts +122 -21
  146. package/dist/cjs/query-creator.js +56 -3
  147. package/dist/cjs/raw-builder/raw-builder.d.ts +29 -7
  148. package/dist/cjs/raw-builder/raw-builder.js +1 -2
  149. package/dist/cjs/raw-builder/sql.d.ts +31 -12
  150. package/dist/cjs/schema/alter-column-builder.d.ts +17 -3
  151. package/dist/cjs/schema/alter-column-builder.js +20 -3
  152. package/dist/cjs/schema/alter-table-add-index-builder.d.ts +44 -10
  153. package/dist/cjs/schema/alter-table-add-index-builder.js +27 -10
  154. package/dist/cjs/schema/alter-table-builder.js +1 -2
  155. package/dist/cjs/schema/column-definition-builder.d.ts +286 -24
  156. package/dist/cjs/schema/column-definition-builder.js +288 -24
  157. package/dist/cjs/schema/create-table-builder.d.ts +86 -33
  158. package/dist/cjs/schema/create-table-builder.js +86 -33
  159. package/dist/cjs/util/assert.js +2 -3
  160. package/dist/cjs/util/column-type.d.ts +5 -9
  161. package/dist/cjs/util/compilable.js +1 -2
  162. package/dist/cjs/util/json-object-args.js +1 -2
  163. package/dist/cjs/util/log-once.js +1 -2
  164. package/dist/cjs/util/object-utils.js +38 -26
  165. package/dist/cjs/util/performance-now.js +1 -2
  166. package/dist/cjs/util/prevent-await.js +1 -2
  167. package/dist/cjs/util/query-id.js +1 -2
  168. package/dist/cjs/util/random-string.js +1 -2
  169. package/dist/cjs/util/require-all-props.d.ts +4 -2
  170. package/dist/cjs/util/require-all-props.js +5 -4
  171. package/dist/cjs/util/stack-trace-utils.js +1 -2
  172. package/dist/cjs/util/streamable.d.ts +1 -1
  173. package/dist/cjs/util/type-utils.d.ts +4 -2
  174. package/dist/esm/dialect/dialect-adapter-base.d.ts +13 -3
  175. package/dist/esm/dialect/dialect-adapter-base.js +4 -1
  176. package/dist/esm/dialect/dialect-adapter.d.ts +16 -2
  177. package/dist/esm/dialect/mssql/mssql-adapter.d.ts +12 -7
  178. package/dist/esm/dialect/mssql/mssql-adapter.js +2 -4
  179. package/dist/esm/dialect/mssql/mssql-dialect-config.d.ts +83 -55
  180. package/dist/esm/dialect/mssql/mssql-driver.d.ts +1 -0
  181. package/dist/esm/dialect/mssql/mssql-driver.js +114 -48
  182. package/dist/esm/dialect/mysql/mysql-adapter.d.ts +11 -2
  183. package/dist/esm/dialect/mysql/mysql-dialect-config.d.ts +4 -0
  184. package/dist/esm/dialect/mysql/mysql-driver.js +3 -0
  185. package/dist/esm/dialect/postgres/postgres-adapter.d.ts +11 -2
  186. package/dist/esm/dialect/postgres/postgres-dialect-config.d.ts +10 -3
  187. package/dist/esm/dialect/postgres/postgres-driver.js +3 -0
  188. package/dist/esm/dialect/postgres/postgres-introspector.js +5 -1
  189. package/dist/esm/dialect/sqlite/sqlite-adapter.d.ts +11 -2
  190. package/dist/esm/driver/database-connection.d.ts +3 -1
  191. package/dist/esm/driver/dummy-driver.d.ts +13 -12
  192. package/dist/esm/driver/dummy-driver.js +13 -12
  193. package/dist/esm/dynamic/dynamic.d.ts +7 -7
  194. package/dist/esm/dynamic/dynamic.js +7 -7
  195. package/dist/esm/expression/expression-builder.d.ts +153 -62
  196. package/dist/esm/expression/expression-wrapper.d.ts +92 -23
  197. package/dist/esm/expression/expression.d.ts +40 -5
  198. package/dist/esm/helpers/mssql.d.ts +74 -14
  199. package/dist/esm/helpers/mssql.js +74 -14
  200. package/dist/esm/helpers/mysql.d.ts +17 -13
  201. package/dist/esm/helpers/mysql.js +17 -13
  202. package/dist/esm/helpers/postgres.d.ts +11 -8
  203. package/dist/esm/helpers/postgres.js +11 -8
  204. package/dist/esm/helpers/sqlite.d.ts +41 -16
  205. package/dist/esm/helpers/sqlite.js +41 -16
  206. package/dist/esm/index.d.ts +28 -21
  207. package/dist/esm/index.js +28 -21
  208. package/dist/esm/kysely.d.ts +100 -42
  209. package/dist/esm/kysely.js +61 -37
  210. package/dist/esm/migration/file-migration-provider.d.ts +2 -2
  211. package/dist/esm/migration/file-migration-provider.js +2 -2
  212. package/dist/esm/migration/migrator.d.ts +82 -14
  213. package/dist/esm/migration/migrator.js +82 -14
  214. package/dist/esm/operation-node/aggregate-function-node.d.ts +4 -0
  215. package/dist/esm/operation-node/aggregate-function-node.js +9 -0
  216. package/dist/esm/operation-node/alter-column-node.d.ts +1 -1
  217. package/dist/esm/operation-node/case-node.d.ts +1 -1
  218. package/dist/esm/operation-node/column-definition-node.d.ts +1 -0
  219. package/dist/esm/operation-node/data-type-node.d.ts +2 -2
  220. package/dist/esm/operation-node/data-type-node.js +15 -1
  221. package/dist/esm/operation-node/delete-query-node.d.ts +3 -0
  222. package/dist/esm/operation-node/foreign-key-constraint-node.d.ts +4 -4
  223. package/dist/esm/operation-node/having-node.d.ts +1 -1
  224. package/dist/esm/operation-node/insert-query-node.d.ts +3 -0
  225. package/dist/esm/operation-node/merge-query-node.d.ts +3 -0
  226. package/dist/esm/operation-node/on-node.d.ts +1 -1
  227. package/dist/esm/operation-node/operation-node-transformer.d.ts +11 -3
  228. package/dist/esm/operation-node/operation-node-transformer.js +26 -3
  229. package/dist/esm/operation-node/operation-node-visitor.d.ts +2 -0
  230. package/dist/esm/operation-node/operation-node-visitor.js +1 -0
  231. package/dist/esm/operation-node/operation-node.d.ts +1 -1
  232. package/dist/esm/operation-node/operator-node.d.ts +3 -3
  233. package/dist/esm/operation-node/operator-node.js +2 -0
  234. package/dist/esm/operation-node/output-node.d.ts +13 -0
  235. package/dist/esm/operation-node/output-node.js +24 -0
  236. package/dist/esm/operation-node/query-node.d.ts +15 -6
  237. package/dist/esm/operation-node/query-node.js +17 -0
  238. package/dist/esm/operation-node/select-query-node.d.ts +1 -1
  239. package/dist/esm/operation-node/select-query-node.js +6 -8
  240. package/dist/esm/operation-node/update-query-node.d.ts +3 -0
  241. package/dist/esm/operation-node/where-node.d.ts +1 -1
  242. package/dist/esm/parser/returning-parser.d.ts +4 -3
  243. package/dist/esm/plugin/camel-case/camel-case-plugin.d.ts +54 -27
  244. package/dist/esm/plugin/camel-case/camel-case-plugin.js +26 -21
  245. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.d.ts +29 -7
  246. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-plugin.js +1 -1
  247. package/dist/esm/plugin/deduplicate-joins/deduplicate-joins-transformer.js +2 -2
  248. package/dist/esm/plugin/immediate-value/immediate-value-plugin.d.ts +28 -6
  249. package/dist/esm/plugin/kysely-plugin.d.ts +28 -6
  250. package/dist/esm/plugin/noop-plugin.d.ts +28 -6
  251. package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.d.ts +80 -9
  252. package/dist/esm/plugin/parse-json-results/parse-json-results-plugin.js +53 -14
  253. package/dist/esm/plugin/with-schema/with-schema-plugin.d.ts +28 -6
  254. package/dist/esm/query-builder/aggregate-function-builder.d.ts +43 -1
  255. package/dist/esm/query-builder/aggregate-function-builder.js +30 -0
  256. package/dist/esm/query-builder/delete-query-builder.d.ts +219 -43
  257. package/dist/esm/query-builder/delete-query-builder.js +95 -31
  258. package/dist/esm/query-builder/function-module.d.ts +40 -93
  259. package/dist/esm/query-builder/insert-query-builder.d.ts +326 -67
  260. package/dist/esm/query-builder/insert-query-builder.js +212 -61
  261. package/dist/esm/query-builder/insert-result.d.ts +10 -5
  262. package/dist/esm/query-builder/insert-result.js +10 -5
  263. package/dist/esm/query-builder/json-path-builder.d.ts +33 -9
  264. package/dist/esm/query-builder/json-path-builder.js +8 -5
  265. package/dist/esm/query-builder/merge-query-builder.d.ts +312 -10
  266. package/dist/esm/query-builder/merge-query-builder.js +98 -7
  267. package/dist/esm/query-builder/on-conflict-builder.d.ts +53 -20
  268. package/dist/esm/query-builder/on-conflict-builder.js +41 -16
  269. package/dist/esm/query-builder/output-interface.d.ts +138 -0
  270. package/dist/esm/query-builder/output-interface.js +2 -0
  271. package/dist/esm/query-builder/returning-interface.d.ts +7 -5
  272. package/dist/esm/query-builder/select-query-builder-expression.d.ts +8 -0
  273. package/dist/esm/query-builder/select-query-builder.d.ts +370 -73
  274. package/dist/esm/query-builder/select-query-builder.js +13 -7
  275. package/dist/esm/query-builder/update-query-builder.d.ts +225 -31
  276. package/dist/esm/query-builder/update-query-builder.js +96 -17
  277. package/dist/esm/query-builder/update-result.d.ts +9 -0
  278. package/dist/esm/query-builder/update-result.js +9 -0
  279. package/dist/esm/query-builder/where-interface.d.ts +6 -2
  280. package/dist/esm/query-compiler/default-query-compiler.d.ts +2 -0
  281. package/dist/esm/query-compiler/default-query-compiler.js +45 -1
  282. package/dist/esm/query-creator.d.ts +122 -21
  283. package/dist/esm/query-creator.js +56 -3
  284. package/dist/esm/raw-builder/raw-builder.d.ts +29 -7
  285. package/dist/esm/raw-builder/sql.d.ts +31 -12
  286. package/dist/esm/schema/alter-column-builder.d.ts +17 -3
  287. package/dist/esm/schema/alter-column-builder.js +20 -3
  288. package/dist/esm/schema/alter-table-add-index-builder.d.ts +44 -10
  289. package/dist/esm/schema/alter-table-add-index-builder.js +27 -10
  290. package/dist/esm/schema/alter-table-builder.js +1 -2
  291. package/dist/esm/schema/column-definition-builder.d.ts +286 -24
  292. package/dist/esm/schema/column-definition-builder.js +288 -24
  293. package/dist/esm/schema/create-table-builder.d.ts +86 -33
  294. package/dist/esm/schema/create-table-builder.js +86 -33
  295. package/dist/esm/util/column-type.d.ts +5 -9
  296. package/dist/esm/util/object-utils.js +18 -5
  297. package/dist/esm/util/require-all-props.d.ts +4 -2
  298. package/dist/esm/util/require-all-props.js +4 -2
  299. package/dist/esm/util/streamable.d.ts +1 -1
  300. package/dist/esm/util/type-utils.d.ts +4 -2
  301. package/package.json +30 -24
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonBuildObject = exports.jsonObjectFrom = exports.jsonArrayFrom = void 0;
3
+ exports.jsonArrayFrom = jsonArrayFrom;
4
+ exports.jsonObjectFrom = jsonObjectFrom;
5
+ exports.jsonBuildObject = jsonBuildObject;
4
6
  const sql_js_1 = require("../raw-builder/sql.js");
5
7
  /**
6
8
  * An MS SQL Server helper for aggregating a subquery into a JSON array.
@@ -11,8 +13,26 @@ const sql_js_1 = require("../raw-builder/sql.js");
11
13
  * The plugin can be installed like this:
12
14
  *
13
15
  * ```ts
14
- * const db = new Kysely({
15
- * dialect: new MssqlDialect(config),
16
+ * import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
17
+ * import * as Tarn from 'tarn'
18
+ * import * as Tedious from 'tedious'
19
+ * import type { Database } from 'type-editor' // imaginary module
20
+ *
21
+ * const db = new Kysely<Database>({
22
+ * dialect: new MssqlDialect({
23
+ * tarn: { options: { max: 10, min: 0 }, ...Tarn },
24
+ * tedious: {
25
+ * ...Tedious,
26
+ * connectionFactory: () => new Tedious.Connection({
27
+ * authentication: {
28
+ * options: { password: 'password', userName: 'sa' },
29
+ * type: 'default',
30
+ * },
31
+ * options: { database: 'test', port: 21433, trustServerCertificate: true },
32
+ * server: 'localhost',
33
+ * }),
34
+ * },
35
+ * }),
16
36
  * plugins: [new ParseJSONResultsPlugin()]
17
37
  * })
18
38
  * ```
@@ -20,6 +40,8 @@ const sql_js_1 = require("../raw-builder/sql.js");
20
40
  * ### Examples
21
41
  *
22
42
  * ```ts
43
+ * import { jsonArrayFrom } from 'kysely/helpers/mssql'
44
+ *
23
45
  * const result = await db
24
46
  * .selectFrom('person')
25
47
  * .select((eb) => [
@@ -29,14 +51,14 @@ const sql_js_1 = require("../raw-builder/sql.js");
29
51
  * .select(['pet.id as pet_id', 'pet.name'])
30
52
  * .whereRef('pet.owner_id', '=', 'person.id')
31
53
  * .orderBy('pet.name')
32
- * .modifyEnd(sql`offset 0 rows`)
54
+ * .offset(0)
33
55
  * ).as('pets')
34
56
  * ])
35
57
  * .execute()
36
58
  *
37
- * result[0].id
38
- * result[0].pets[0].pet_id
39
- * result[0].pets[0].name
59
+ * result[0]?.id
60
+ * result[0]?.pets[0]?.pet_id
61
+ * result[0]?.pets[0]?.name
40
62
  * ```
41
63
  *
42
64
  * The generated SQL (MS SQL Server):
@@ -48,7 +70,7 @@ const sql_js_1 = require("../raw-builder/sql.js");
48
70
  * from "pet"
49
71
  * where "pet"."owner_id" = "person"."id"
50
72
  * order by "pet"."name"
51
- * offset 0 rows
73
+ * offset @1 rows
52
74
  * ) as "agg" for json path, include_null_values), '[]')
53
75
  * ) as "pets"
54
76
  * from "person"
@@ -57,7 +79,6 @@ const sql_js_1 = require("../raw-builder/sql.js");
57
79
  function jsonArrayFrom(expr) {
58
80
  return (0, sql_js_1.sql) `coalesce((select * from ${expr} as agg for json path, include_null_values), '[]')`;
59
81
  }
60
- exports.jsonArrayFrom = jsonArrayFrom;
61
82
  /**
62
83
  * An MS SQL Server helper for turning a subquery into a JSON object.
63
84
  *
@@ -69,8 +90,26 @@ exports.jsonArrayFrom = jsonArrayFrom;
69
90
  * The plugin can be installed like this:
70
91
  *
71
92
  * ```ts
72
- * const db = new Kysely({
73
- * dialect: new MssqlDialect(config),
93
+ * import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
94
+ * import * as Tarn from 'tarn'
95
+ * import * as Tedious from 'tedious'
96
+ * import type { Database } from 'type-editor' // imaginary module
97
+ *
98
+ * const db = new Kysely<Database>({
99
+ * dialect: new MssqlDialect({
100
+ * tarn: { options: { max: 10, min: 0 }, ...Tarn },
101
+ * tedious: {
102
+ * ...Tedious,
103
+ * connectionFactory: () => new Tedious.Connection({
104
+ * authentication: {
105
+ * options: { password: 'password', userName: 'sa' },
106
+ * type: 'default',
107
+ * },
108
+ * options: { database: 'test', port: 21433, trustServerCertificate: true },
109
+ * server: 'localhost',
110
+ * }),
111
+ * },
112
+ * }),
74
113
  * plugins: [new ParseJSONResultsPlugin()]
75
114
  * })
76
115
  * ```
@@ -78,6 +117,8 @@ exports.jsonArrayFrom = jsonArrayFrom;
78
117
  * ### Examples
79
118
  *
80
119
  * ```ts
120
+ * import { jsonObjectFrom } from 'kysely/helpers/mssql'
121
+ *
81
122
  * const result = await db
82
123
  * .selectFrom('person')
83
124
  * .select((eb) => [
@@ -91,9 +132,9 @@ exports.jsonArrayFrom = jsonArrayFrom;
91
132
  * ])
92
133
  * .execute()
93
134
  *
94
- * result[0].id
95
- * result[0].favorite_pet.pet_id
96
- * result[0].favorite_pet.name
135
+ * result[0]?.id
136
+ * result[0]?.favorite_pet?.pet_id
137
+ * result[0]?.favorite_pet?.name
97
138
  * ```
98
139
  *
99
140
  * The generated SQL (MS SQL Server):
@@ -113,7 +154,6 @@ exports.jsonArrayFrom = jsonArrayFrom;
113
154
  function jsonObjectFrom(expr) {
114
155
  return (0, sql_js_1.sql) `(select * from ${expr} as agg for json path, include_null_values, without_array_wrapper)`;
115
156
  }
116
- exports.jsonObjectFrom = jsonObjectFrom;
117
157
  /**
118
158
  * The MS SQL Server `json_query` function, single argument variant.
119
159
  *
@@ -123,8 +163,26 @@ exports.jsonObjectFrom = jsonObjectFrom;
123
163
  * The plugin can be installed like this:
124
164
  *
125
165
  * ```ts
126
- * const db = new Kysely({
127
- * dialect: new MssqlDialect(config),
166
+ * import { Kysely, MssqlDialect, ParseJSONResultsPlugin } from 'kysely'
167
+ * import * as Tarn from 'tarn'
168
+ * import * as Tedious from 'tedious'
169
+ * import type { Database } from 'type-editor' // imaginary module
170
+ *
171
+ * const db = new Kysely<Database>({
172
+ * dialect: new MssqlDialect({
173
+ * tarn: { options: { max: 10, min: 0 }, ...Tarn },
174
+ * tedious: {
175
+ * ...Tedious,
176
+ * connectionFactory: () => new Tedious.Connection({
177
+ * authentication: {
178
+ * options: { password: 'password', userName: 'sa' },
179
+ * type: 'default',
180
+ * },
181
+ * options: { database: 'test', port: 21433, trustServerCertificate: true },
182
+ * server: 'localhost',
183
+ * }),
184
+ * },
185
+ * }),
128
186
  * plugins: [new ParseJSONResultsPlugin()]
129
187
  * })
130
188
  * ```
@@ -132,6 +190,8 @@ exports.jsonObjectFrom = jsonObjectFrom;
132
190
  * ### Examples
133
191
  *
134
192
  * ```ts
193
+ * import { jsonBuildObject } from 'kysely/helpers/mssql'
194
+ *
135
195
  * const result = await db
136
196
  * .selectFrom('person')
137
197
  * .select((eb) => [
@@ -157,4 +217,3 @@ exports.jsonObjectFrom = jsonObjectFrom;
157
217
  function jsonBuildObject(obj) {
158
218
  return (0, sql_js_1.sql) `json_query('{${sql_js_1.sql.join(Object.keys(obj).map((k) => (0, sql_js_1.sql) `"${sql_js_1.sql.raw(k)}":"'+${obj[k]}+'"`), (0, sql_js_1.sql) `,`)}}')`;
159
219
  }
160
- exports.jsonBuildObject = jsonBuildObject;
@@ -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 3rd party dialects
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].id
30
- * result[0].pets[0].pet_id
31
- * result[0].pets[0].name
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 3rd party dialects
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].id
79
- * result[0].favorite_pet.pet_id
80
- * result[0].favorite_pet.name
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 3rd party dialects
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].id
125
- * result[0].name.first
126
- * result[0].name.last
127
- * result[0].name.full
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):
@@ -1,19 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonBuildObject = exports.jsonObjectFrom = exports.jsonArrayFrom = void 0;
3
+ exports.jsonArrayFrom = jsonArrayFrom;
4
+ exports.jsonObjectFrom = jsonObjectFrom;
5
+ exports.jsonBuildObject = jsonBuildObject;
4
6
  const sql_js_1 = require("../raw-builder/sql.js");
5
7
  const json_object_args_js_1 = require("../util/json-object-args.js");
6
8
  /**
7
9
  * A MySQL helper for aggregating a subquery into a JSON array.
8
10
  *
9
11
  * NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
10
- * While the produced SQL is compatible with all MySQL databases, some 3rd party dialects
12
+ * While the produced SQL is compatible with all MySQL databases, some third-party dialects
11
13
  * may not parse the nested JSON into arrays. In these cases you can use the built in
12
14
  * `ParseJSONResultsPlugin` to parse the results.
13
15
  *
14
16
  * ### Examples
15
17
  *
16
18
  * ```ts
19
+ * import { jsonArrayFrom } from 'kysely/helpers/mysql'
20
+ *
17
21
  * const result = await db
18
22
  * .selectFrom('person')
19
23
  * .select((eb) => [
@@ -27,9 +31,9 @@ const json_object_args_js_1 = require("../util/json-object-args.js");
27
31
  * ])
28
32
  * .execute()
29
33
  *
30
- * result[0].id
31
- * result[0].pets[0].pet_id
32
- * result[0].pets[0].name
34
+ * result[0]?.id
35
+ * result[0]?.pets[0]?.pet_id
36
+ * result[0]?.pets[0]?.name
33
37
  * ```
34
38
  *
35
39
  * The generated SQL (MySQL):
@@ -52,20 +56,21 @@ const json_object_args_js_1 = require("../util/json-object-args.js");
52
56
  function jsonArrayFrom(expr) {
53
57
  return (0, sql_js_1.sql) `(select cast(coalesce(json_arrayagg(json_object(${sql_js_1.sql.join(getMysqlJsonObjectArgs(expr.toOperationNode(), 'agg'))})), '[]') as json) from ${expr} as agg)`;
54
58
  }
55
- exports.jsonArrayFrom = jsonArrayFrom;
56
59
  /**
57
60
  * A MySQL helper for turning a subquery into a JSON object.
58
61
  *
59
62
  * The subquery must only return one row.
60
63
  *
61
64
  * NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
62
- * While the produced SQL is compatible with all MySQL databases, some 3rd party dialects
65
+ * While the produced SQL is compatible with all MySQL databases, some third-party dialects
63
66
  * may not parse the nested JSON into objects. In these cases you can use the built in
64
67
  * `ParseJSONResultsPlugin` to parse the results.
65
68
  *
66
69
  * ### Examples
67
70
  *
68
71
  * ```ts
72
+ * import { jsonObjectFrom } from 'kysely/helpers/mysql'
73
+ *
69
74
  * const result = await db
70
75
  * .selectFrom('person')
71
76
  * .select((eb) => [
@@ -79,9 +84,9 @@ exports.jsonArrayFrom = jsonArrayFrom;
79
84
  * ])
80
85
  * .execute()
81
86
  *
82
- * result[0].id
83
- * result[0].favorite_pet.pet_id
84
- * result[0].favorite_pet.name
87
+ * result[0]?.id
88
+ * result[0]?.favorite_pet?.pet_id
89
+ * result[0]?.favorite_pet?.name
85
90
  * ```
86
91
  *
87
92
  * The generated SQL (MySQL):
@@ -104,12 +109,11 @@ exports.jsonArrayFrom = jsonArrayFrom;
104
109
  function jsonObjectFrom(expr) {
105
110
  return (0, sql_js_1.sql) `(select json_object(${sql_js_1.sql.join(getMysqlJsonObjectArgs(expr.toOperationNode(), 'obj'))}) from ${expr} as obj)`;
106
111
  }
107
- exports.jsonObjectFrom = jsonObjectFrom;
108
112
  /**
109
113
  * The MySQL `json_object` function.
110
114
  *
111
115
  * NOTE: This helper is only guaranteed to fully work with the built-in `MysqlDialect`.
112
- * While the produced SQL is compatible with all MySQL databases, some 3rd party dialects
116
+ * While the produced SQL is compatible with all MySQL databases, some third-party dialects
113
117
  * may not parse the nested JSON into objects. In these cases you can use the built in
114
118
  * `ParseJSONResultsPlugin` to parse the results.
115
119
  *
@@ -128,10 +132,10 @@ exports.jsonObjectFrom = jsonObjectFrom;
128
132
  * ])
129
133
  * .execute()
130
134
  *
131
- * result[0].id
132
- * result[0].name.first
133
- * result[0].name.last
134
- * result[0].name.full
135
+ * result[0]?.id
136
+ * result[0]?.name.first
137
+ * result[0]?.name.last
138
+ * result[0]?.name.full
135
139
  * ```
136
140
  *
137
141
  * The generated SQL (MySQL):
@@ -148,7 +152,6 @@ exports.jsonObjectFrom = jsonObjectFrom;
148
152
  function jsonBuildObject(obj) {
149
153
  return (0, sql_js_1.sql) `json_object(${sql_js_1.sql.join(Object.keys(obj).flatMap((k) => [sql_js_1.sql.lit(k), obj[k]]))})`;
150
154
  }
151
- exports.jsonBuildObject = jsonBuildObject;
152
155
  function getMysqlJsonObjectArgs(node, table) {
153
156
  try {
154
157
  return (0, json_object_args_js_1.getJsonObjectArgs)(node, table);
@@ -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
- * javascript JSON values like objects and arrays. Some dialects might simply return
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 3rd party dialects. In order for
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
- * javascript JSON values like objects and arrays. Some dialects might simply return
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 3rd party dialects
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].id
130
- * result[0].name.first
131
- * result[0].name.last
132
- * result[0].name.full
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):
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonBuildObject = exports.jsonObjectFrom = exports.jsonArrayFrom = void 0;
3
+ exports.jsonArrayFrom = jsonArrayFrom;
4
+ exports.jsonObjectFrom = jsonObjectFrom;
5
+ exports.jsonBuildObject = jsonBuildObject;
4
6
  const sql_js_1 = require("../raw-builder/sql.js");
5
7
  /**
6
8
  * A postgres helper for aggregating a subquery (or other expression) into a JSONB array.
@@ -16,7 +18,7 @@ const sql_js_1 = require("../raw-builder/sql.js");
16
18
  * Please keep in mind that the helpers under the `kysely/helpers` folder, including
17
19
  * `jsonArrayFrom`, are not guaranteed to work with third party dialects. In order for
18
20
  * them to work, the dialect must automatically parse the `json` data type into
19
- * javascript JSON values like objects and arrays. Some dialects might simply return
21
+ * JavaScript JSON values like objects and arrays. Some dialects might simply return
20
22
  * the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
21
23
  * to parse the results.
22
24
  *
@@ -54,7 +56,6 @@ const sql_js_1 = require("../raw-builder/sql.js");
54
56
  function jsonArrayFrom(expr) {
55
57
  return (0, sql_js_1.sql) `(select coalesce(json_agg(agg), '[]') from ${expr} as agg)`;
56
58
  }
57
- exports.jsonArrayFrom = jsonArrayFrom;
58
59
  /**
59
60
  * A postgres helper for turning a subquery (or other expression) into a JSON object.
60
61
  *
@@ -69,9 +70,9 @@ exports.jsonArrayFrom = jsonArrayFrom;
69
70
  * use the `jsonObjectFrom` helper to fetch person's favorite pet along with the person's id.
70
71
  *
71
72
  * Please keep in mind that the helpers under the `kysely/helpers` folder, including
72
- * `jsonObjectFrom`, are not guaranteed to work with 3rd party dialects. In order for
73
+ * `jsonObjectFrom`, are not guaranteed to work with third-party dialects. In order for
73
74
  * them to work, the dialect must automatically parse the `json` data type into
74
- * javascript JSON values like objects and arrays. Some dialects might simply return
75
+ * JavaScript JSON values like objects and arrays. Some dialects might simply return
75
76
  * the data as a JSON string. In these cases you can use the built in `ParseJSONResultsPlugin`
76
77
  * to parse the results.
77
78
  *
@@ -109,18 +110,20 @@ exports.jsonArrayFrom = jsonArrayFrom;
109
110
  function jsonObjectFrom(expr) {
110
111
  return (0, sql_js_1.sql) `(select to_json(obj) from ${expr} as obj)`;
111
112
  }
112
- exports.jsonObjectFrom = jsonObjectFrom;
113
113
  /**
114
114
  * The PostgreSQL `json_build_object` function.
115
115
  *
116
116
  * NOTE: This helper is only guaranteed to fully work with the built-in `PostgresDialect`.
117
- * While the produced SQL is compatible with all PostgreSQL databases, some 3rd party dialects
117
+ * While the produced SQL is compatible with all PostgreSQL databases, some third-party dialects
118
118
  * may not parse the nested JSON into objects. In these cases you can use the built in
119
119
  * `ParseJSONResultsPlugin` to parse the results.
120
120
  *
121
121
  * ### Examples
122
122
  *
123
123
  * ```ts
124
+ * import { sql } from 'kysely'
125
+ * import { jsonBuildObject } from 'kysely/helpers/postgres'
126
+ *
124
127
  * const result = await db
125
128
  * .selectFrom('person')
126
129
  * .select((eb) => [
@@ -133,10 +136,10 @@ exports.jsonObjectFrom = jsonObjectFrom;
133
136
  * ])
134
137
  * .execute()
135
138
  *
136
- * result[0].id
137
- * result[0].name.first
138
- * result[0].name.last
139
- * result[0].name.full
139
+ * result[0]?.id
140
+ * result[0]?.name.first
141
+ * result[0]?.name.last
142
+ * result[0]?.name.full
140
143
  * ```
141
144
  *
142
145
  * The generated SQL (PostgreSQL):
@@ -153,4 +156,3 @@ exports.jsonObjectFrom = jsonObjectFrom;
153
156
  function jsonBuildObject(obj) {
154
157
  return (0, sql_js_1.sql) `json_build_object(${sql_js_1.sql.join(Object.keys(obj).flatMap((k) => [sql_js_1.sql.lit(k), obj[k]]))})`;
155
158
  }
156
- exports.jsonBuildObject = jsonBuildObject;
@@ -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
- * const db = new Kysely({
15
- * dialect: new SqliteDialect(config),
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].id
37
- * result[0].pets[0].pet_id
38
- * result[0].pets[0].name
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
- * const db = new Kysely({
71
- * dialect: new SqliteDialect(config),
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].id
93
- * result[0].favorite_pet.pet_id
94
- * result[0].favorite_pet.name
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
- * const db = new Kysely({
125
- * dialect: new SqliteDialect(config),
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].id
146
- * result[0].name.first
147
- * result[0].name.last
148
- * result[0].name.full
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):