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
@@ -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 it's own connection pool.
23
+ * constructor. Each `Kysely` instance maintains its own connection pool.
24
24
  *
25
25
  * ### Examples
26
26
  *
27
- * This example assumes your database has tables `person` and `pet`:
27
+ * This example assumes your database has a "person" table:
28
28
  *
29
29
  * ```ts
30
- * import { Kysely, Generated, PostgresDialect } from 'kysely'
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: PersonTable,
47
- * pet: PetTable
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 PostgresDialect({
52
- * host: 'localhost',
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 safe function
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((eb) => [
96
- * 'person.id',
97
- * eb.fn.count('pet.id').as('pet_count')
87
+ * .select([
88
+ * 'id',
89
+ * count('pet.id').as('person_count'),
98
90
  * ])
99
91
  * .groupBy('person.id')
100
- * .having((eb) => eb.fn.count('pet.id'), '>', 10)
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 "pet_count"
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, the transaction is rolled back. Otherwise
122
- * the transaction is committed.
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 error is thrown inside
134
- * the callback passed to the `execute` method, the transaction is rolled back.
135
- * Otherwise it's committed.
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/koskimas/kysely/blob/master/site/docs/recipes/splitting-build-compile-and-execute-code.md#execute-compiled-queries splitting build, compile and execute code recipe} for more information.
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, the transaction is rolled back. Otherwise
273
- * the transaction is committed.
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 error is thrown inside
285
- * the callback passed to the `execute` method, the transaction is rolled back.
286
- * Otherwise it's committed.
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 PostgresDialect(postgresConfig),
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 PostgresDialect(postgresConfig),
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)
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransactionBuilder = exports.ConnectionBuilder = exports.isKyselyProps = exports.Transaction = exports.Kysely = void 0;
3
+ exports.TransactionBuilder = exports.ConnectionBuilder = exports.Transaction = exports.Kysely = void 0;
4
+ exports.isKyselyProps = isKyselyProps;
4
5
  const schema_js_1 = require("./schema/schema.js");
5
6
  const dynamic_js_1 = require("./dynamic/dynamic.js");
6
7
  const default_connection_provider_js_1 = require("./driver/default-connection-provider.js");
@@ -23,37 +24,27 @@ const with_schema_plugin_js_1 = require("./plugin/with-schema/with-schema-plugin
23
24
  * The main Kysely class.
24
25
  *
25
26
  * You should create one instance of `Kysely` per database using the {@link Kysely}
26
- * constructor. Each `Kysely` instance maintains it's own connection pool.
27
+ * constructor. Each `Kysely` instance maintains its own connection pool.
27
28
  *
28
29
  * ### Examples
29
30
  *
30
- * This example assumes your database has tables `person` and `pet`:
31
+ * This example assumes your database has a "person" table:
31
32
  *
32
33
  * ```ts
33
- * import { Kysely, Generated, PostgresDialect } from 'kysely'
34
- *
35
- * interface PersonTable {
36
- * id: Generated<number>
37
- * first_name: string
38
- * last_name: string
39
- * }
40
- *
41
- * interface PetTable {
42
- * id: Generated<number>
43
- * owner_id: number
44
- * name: string
45
- * species: 'cat' | 'dog'
46
- * }
34
+ * import * as Sqlite from 'better-sqlite3'
35
+ * import { type Generated, Kysely, SqliteDialect } from 'kysely'
47
36
  *
48
37
  * interface Database {
49
- * person: PersonTable,
50
- * pet: PetTable
38
+ * person: {
39
+ * id: Generated<number>
40
+ * first_name: string
41
+ * last_name: string | null
42
+ * }
51
43
  * }
52
44
  *
53
45
  * const db = new Kysely<Database>({
54
- * dialect: new PostgresDialect({
55
- * host: 'localhost',
56
- * database: 'kysely_test',
46
+ * dialect: new SqliteDialect({
47
+ * database: new Sqlite(':memory:'),
57
48
  * })
58
49
  * })
59
50
  * ```
@@ -118,30 +109,52 @@ class Kysely extends query_creator_js_1.QueryCreator {
118
109
  });
119
110
  }
120
111
  /**
121
- * Returns a {@link FunctionModule} that can be used to write type safe function
112
+ * Returns a {@link FunctionModule} that can be used to write somewhat type-safe function
122
113
  * calls.
123
114
  *
124
115
  * ```ts
116
+ * const { count } = db.fn
117
+ *
125
118
  * await db.selectFrom('person')
126
119
  * .innerJoin('pet', 'pet.owner_id', 'person.id')
127
- * .select((eb) => [
128
- * 'person.id',
129
- * eb.fn.count('pet.id').as('pet_count')
120
+ * .select([
121
+ * 'id',
122
+ * count('pet.id').as('person_count'),
130
123
  * ])
131
124
  * .groupBy('person.id')
132
- * .having((eb) => eb.fn.count('pet.id'), '>', 10)
125
+ * .having(count('pet.id'), '>', 10)
133
126
  * .execute()
134
127
  * ```
135
128
  *
136
129
  * The generated SQL (PostgreSQL):
137
130
  *
138
131
  * ```sql
139
- * select "person"."id", count("pet"."id") as "pet_count"
132
+ * select "person"."id", count("pet"."id") as "person_count"
140
133
  * from "person"
141
134
  * inner join "pet" on "pet"."owner_id" = "person"."id"
142
135
  * group by "person"."id"
143
136
  * having count("pet"."id") > $1
144
137
  * ```
138
+ *
139
+ * Why "somewhat" type-safe? Because the function calls are not bound to the
140
+ * current query context. They allow you to reference columns and tables that
141
+ * are not in the current query. E.g. remove the `innerJoin` from the previous
142
+ * query and TypeScript won't even complain.
143
+ *
144
+ * If you want to make the function calls fully type-safe, you can use the
145
+ * {@link ExpressionBuilder.fn} getter for a query context-aware, stricter {@link FunctionModule}.
146
+ *
147
+ * ```ts
148
+ * await db.selectFrom('person')
149
+ * .innerJoin('pet', 'pet.owner_id', 'person.id')
150
+ * .select((eb) => [
151
+ * 'person.id',
152
+ * eb.fn.count('pet.id').as('pet_count')
153
+ * ])
154
+ * .groupBy('person.id')
155
+ * .having((eb) => eb.fn.count('pet.id'), '>', 10)
156
+ * .execute()
157
+ * ```
145
158
  */
146
159
  get fn() {
147
160
  return (0, function_module_js_1.createFunctionModule)();
@@ -152,8 +165,11 @@ class Kysely extends query_creator_js_1.QueryCreator {
152
165
  * The returned {@link TransactionBuilder} can be used to configure the transaction. The
153
166
  * {@link TransactionBuilder.execute} method can then be called to run the transaction.
154
167
  * {@link TransactionBuilder.execute} takes a function that is run inside the
155
- * transaction. If the function throws, the transaction is rolled back. Otherwise
156
- * the transaction is committed.
168
+ * transaction. If the function throws an exception,
169
+ * 1. the exception is caught,
170
+ * 2. the transaction is rolled back, and
171
+ * 3. the exception is thrown again.
172
+ * Otherwise the transaction is committed.
157
173
  *
158
174
  * The callback function passed to the {@link TransactionBuilder.execute | execute}
159
175
  * method gets the transaction object as its only argument. The transaction is
@@ -164,9 +180,12 @@ class Kysely extends query_creator_js_1.QueryCreator {
164
180
  *
165
181
  * <!-- siteExample("transactions", "Simple transaction", 10) -->
166
182
  *
167
- * This example inserts two rows in a transaction. If an error is thrown inside
168
- * the callback passed to the `execute` method, the transaction is rolled back.
169
- * Otherwise it's committed.
183
+ * This example inserts two rows in a transaction. If an exception is thrown inside
184
+ * the callback passed to the `execute` method,
185
+ * 1. the exception is caught,
186
+ * 2. the transaction is rolled back, and
187
+ * 3. the exception is thrown again.
188
+ * Otherwise the transaction is committed.
170
189
  *
171
190
  * ```ts
172
191
  * const catto = await db.transaction().execute(async (trx) => {
@@ -194,12 +213,18 @@ class Kysely extends query_creator_js_1.QueryCreator {
194
213
  * Setting the isolation level:
195
214
  *
196
215
  * ```ts
216
+ * import type { Kysely } from 'kysely'
217
+ *
197
218
  * await db
198
219
  * .transaction()
199
220
  * .setIsolationLevel('serializable')
200
221
  * .execute(async (trx) => {
201
222
  * await doStuff(trx)
202
223
  * })
224
+ *
225
+ * async function doStuff(kysely: typeof db) {
226
+ * // ...
227
+ * }
203
228
  * ```
204
229
  */
205
230
  transaction() {
@@ -219,6 +244,10 @@ class Kysely extends query_creator_js_1.QueryCreator {
219
244
  * // the same connection.
220
245
  * await doStuff(db)
221
246
  * })
247
+ *
248
+ * async function doStuff(kysely: typeof db) {
249
+ * // ...
250
+ * }
222
251
  * ```
223
252
  */
224
253
  connection() {
@@ -262,7 +291,6 @@ class Kysely extends query_creator_js_1.QueryCreator {
262
291
  *
263
292
  * The following example adds and uses a temporary table:
264
293
  *
265
- * @example
266
294
  * ```ts
267
295
  * await db.schema
268
296
  * .createTable('temp_table')
@@ -311,7 +339,7 @@ class Kysely extends query_creator_js_1.QueryCreator {
311
339
  /**
312
340
  * Executes a given compiled query or query builder.
313
341
  *
314
- * See {@link https://github.com/koskimas/kysely/blob/master/site/docs/recipes/splitting-build-compile-and-execute-code.md#execute-compiled-queries splitting build, compile and execute code recipe} for more information.
342
+ * 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.
315
343
  */
316
344
  executeQuery(query, queryId = (0, query_id_js_1.createQueryId)()) {
317
345
  const compiledQuery = (0, compilable_js_1.isCompilable)(query) ? query.compile() : query;
@@ -352,9 +380,6 @@ class Transaction extends Kysely {
352
380
  executor: this.#props.executor.withoutPlugins(),
353
381
  });
354
382
  }
355
- /**
356
- * @override
357
- */
358
383
  withSchema(schema) {
359
384
  return new Transaction({
360
385
  ...this.#props,
@@ -373,7 +398,6 @@ function isKyselyProps(obj) {
373
398
  (0, object_utils_js_1.isObject)(obj.executor) &&
374
399
  (0, object_utils_js_1.isObject)(obj.dialect));
375
400
  }
376
- exports.isKyselyProps = isKyselyProps;
377
401
  class ConnectionBuilder {
378
402
  #props;
379
403
  constructor(props) {
@@ -5,8 +5,8 @@ import { Migration, MigrationProvider } from './migrator.js';
5
5
  * ### Examples
6
6
  *
7
7
  * ```ts
8
- * import { promises as fs } from 'fs'
9
- * import path from 'path'
8
+ * import { promises as fs } from 'node:fs'
9
+ * import path from 'node:path'
10
10
  *
11
11
  * new FileMigrationProvider({
12
12
  * fs,
@@ -8,8 +8,8 @@ const object_utils_js_1 = require("../util/object-utils.js");
8
8
  * ### Examples
9
9
  *
10
10
  * ```ts
11
- * import { promises as fs } from 'fs'
12
- * import path from 'path'
11
+ * import { promises as fs } from 'node:fs'
12
+ * import path from 'node:path'
13
13
  *
14
14
  * new FileMigrationProvider({
15
15
  * fs,
@@ -25,16 +25,29 @@ export interface Migration {
25
25
  * other way.
26
26
  *
27
27
  * ```ts
28
- * import { promises as fs } from 'fs'
29
- * import path from 'path'
28
+ * import { promises as fs } from 'node:fs'
29
+ * import path from 'node:path'
30
+ * import * as Sqlite from 'better-sqlite3'
31
+ * import {
32
+ * FileMigrationProvider,
33
+ * Kysely,
34
+ * Migrator,
35
+ * SqliteDialect
36
+ * } from 'kysely'
37
+ *
38
+ * const db = new Kysely<any>({
39
+ * dialect: new SqliteDialect({
40
+ * database: Sqlite(':memory:')
41
+ * })
42
+ * })
30
43
  *
31
44
  * const migrator = new Migrator({
32
45
  * db,
33
46
  * provider: new FileMigrationProvider({
34
47
  * fs,
35
- * path,
36
48
  * // Path to the folder that contains all your migrations.
37
- * migrationFolder: 'some/path/to/migrations'
49
+ * migrationFolder: 'some/path/to/migrations',
50
+ * path,
38
51
  * })
39
52
  * })
40
53
  * ```
@@ -64,19 +77,18 @@ export declare class Migrator {
64
77
  * ### Examples
65
78
  *
66
79
  * ```ts
67
- * const db = new Kysely<Database>({
68
- * dialect: new PostgresDialect({
69
- * host: 'localhost',
70
- * database: 'kysely_test',
71
- * }),
72
- * })
80
+ * import { promises as fs } from 'node:fs'
81
+ * import path from 'node:path'
82
+ * import * as Sqlite from 'better-sqlite3'
83
+ * import { FileMigrationProvider, Migrator } from 'kysely'
73
84
  *
74
85
  * const migrator = new Migrator({
75
86
  * db,
76
- * provider: new FileMigrationProvider(
77
- * // Path to the folder that contains all your migrations.
78
- * 'some/path/to/migrations'
79
- * )
87
+ * provider: new FileMigrationProvider({
88
+ * fs,
89
+ * migrationFolder: 'some/path/to/migrations',
90
+ * path,
91
+ * })
80
92
  * })
81
93
  *
82
94
  * const { error, results } = await migrator.migrateToLatest()
@@ -107,6 +119,20 @@ export declare class Migrator {
107
119
  * ### Examples
108
120
  *
109
121
  * ```ts
122
+ * import { promises as fs } from 'node:fs'
123
+ * import path from 'node:path'
124
+ * import { FileMigrationProvider, Migrator } from 'kysely'
125
+ *
126
+ * const migrator = new Migrator({
127
+ * db,
128
+ * provider: new FileMigrationProvider({
129
+ * fs,
130
+ * // Path to the folder that contains all your migrations.
131
+ * migrationFolder: 'some/path/to/migrations',
132
+ * path,
133
+ * })
134
+ * })
135
+ *
110
136
  * await migrator.migrateTo('some_migration')
111
137
  * ```
112
138
  *
@@ -116,6 +142,20 @@ export declare class Migrator {
116
142
  * you can use a special constant `NO_MIGRATIONS`:
117
143
  *
118
144
  * ```ts
145
+ * import { promises as fs } from 'node:fs'
146
+ * import path from 'node:path'
147
+ * import { FileMigrationProvider, Migrator, NO_MIGRATIONS } from 'kysely'
148
+ *
149
+ * const migrator = new Migrator({
150
+ * db,
151
+ * provider: new FileMigrationProvider({
152
+ * fs,
153
+ * // Path to the folder that contains all your migrations.
154
+ * migrationFolder: 'some/path/to/migrations',
155
+ * path,
156
+ * })
157
+ * })
158
+ *
119
159
  * await migrator.migrateTo(NO_MIGRATIONS)
120
160
  * ```
121
161
  */
@@ -131,6 +171,20 @@ export declare class Migrator {
131
171
  * ### Examples
132
172
  *
133
173
  * ```ts
174
+ * import { promises as fs } from 'node:fs'
175
+ * import path from 'node:path'
176
+ * import { FileMigrationProvider, Migrator } from 'kysely'
177
+ *
178
+ * const migrator = new Migrator({
179
+ * db,
180
+ * provider: new FileMigrationProvider({
181
+ * fs,
182
+ * // Path to the folder that contains all your migrations.
183
+ * migrationFolder: 'some/path/to/migrations',
184
+ * path,
185
+ * })
186
+ * })
187
+ *
134
188
  * await migrator.migrateUp()
135
189
  * ```
136
190
  */
@@ -146,6 +200,20 @@ export declare class Migrator {
146
200
  * ### Examples
147
201
  *
148
202
  * ```ts
203
+ * import { promises as fs } from 'node:fs'
204
+ * import path from 'node:path'
205
+ * import { FileMigrationProvider, Migrator } from 'kysely'
206
+ *
207
+ * const migrator = new Migrator({
208
+ * db,
209
+ * provider: new FileMigrationProvider({
210
+ * fs,
211
+ * // Path to the folder that contains all your migrations.
212
+ * migrationFolder: 'some/path/to/migrations',
213
+ * path,
214
+ * })
215
+ * })
216
+ *
149
217
  * await migrator.migrateDown()
150
218
  * ```
151
219
  */