drizzle-orm 0.36.4 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/column-builder.cjs.map +1 -1
  2. package/column-builder.d.cts +4 -3
  3. package/column-builder.d.ts +4 -3
  4. package/column-builder.js.map +1 -1
  5. package/durable-sqlite/driver.cjs +64 -0
  6. package/durable-sqlite/driver.cjs.map +1 -0
  7. package/durable-sqlite/driver.d.cts +9 -0
  8. package/durable-sqlite/driver.d.ts +9 -0
  9. package/durable-sqlite/driver.js +42 -0
  10. package/durable-sqlite/driver.js.map +1 -0
  11. package/durable-sqlite/index.cjs +25 -0
  12. package/durable-sqlite/index.cjs.map +1 -0
  13. package/durable-sqlite/index.d.cts +2 -0
  14. package/durable-sqlite/index.d.ts +2 -0
  15. package/durable-sqlite/index.js +3 -0
  16. package/durable-sqlite/index.js.map +1 -0
  17. package/durable-sqlite/migrator.cjs +85 -0
  18. package/durable-sqlite/migrator.cjs.map +1 -0
  19. package/durable-sqlite/migrator.d.cts +14 -0
  20. package/durable-sqlite/migrator.d.ts +14 -0
  21. package/durable-sqlite/migrator.js +61 -0
  22. package/durable-sqlite/migrator.js.map +1 -0
  23. package/durable-sqlite/session.cjs +131 -0
  24. package/durable-sqlite/session.cjs.map +1 -0
  25. package/durable-sqlite/session.d.cts +46 -0
  26. package/durable-sqlite/session.d.ts +46 -0
  27. package/durable-sqlite/session.js +107 -0
  28. package/durable-sqlite/session.js.map +1 -0
  29. package/neon-http/driver.cjs +1 -1
  30. package/neon-http/driver.cjs.map +1 -1
  31. package/neon-http/driver.d.cts +2 -2
  32. package/neon-http/driver.d.ts +2 -2
  33. package/neon-http/driver.js +1 -1
  34. package/neon-http/driver.js.map +1 -1
  35. package/neon-http/session.cjs.map +1 -1
  36. package/neon-http/session.js.map +1 -1
  37. package/package.json +784 -3
  38. package/pg-core/db.cjs +4 -2
  39. package/pg-core/db.cjs.map +1 -1
  40. package/pg-core/db.d.cts +2 -2
  41. package/pg-core/db.d.ts +2 -2
  42. package/pg-core/db.js +4 -2
  43. package/pg-core/db.js.map +1 -1
  44. package/pg-core/query-builders/count.cjs +1 -0
  45. package/pg-core/query-builders/count.cjs.map +1 -1
  46. package/pg-core/query-builders/count.d.cts +2 -1
  47. package/pg-core/query-builders/count.d.ts +2 -1
  48. package/pg-core/query-builders/count.js +1 -0
  49. package/pg-core/query-builders/count.js.map +1 -1
  50. package/pg-core/query-builders/delete.cjs.map +1 -1
  51. package/pg-core/query-builders/delete.js.map +1 -1
  52. package/pg-core/query-builders/insert.cjs +1 -9
  53. package/pg-core/query-builders/insert.cjs.map +1 -1
  54. package/pg-core/query-builders/insert.js +1 -9
  55. package/pg-core/query-builders/insert.js.map +1 -1
  56. package/pg-core/query-builders/query.cjs.map +1 -1
  57. package/pg-core/query-builders/query.js.map +1 -1
  58. package/pg-core/query-builders/refresh-materialized-view.cjs.map +1 -1
  59. package/pg-core/query-builders/refresh-materialized-view.js.map +1 -1
  60. package/pg-core/query-builders/select.cjs +2 -10
  61. package/pg-core/query-builders/select.cjs.map +1 -1
  62. package/pg-core/query-builders/select.js +8 -11
  63. package/pg-core/query-builders/select.js.map +1 -1
  64. package/pg-core/query-builders/update.cjs +1 -7
  65. package/pg-core/query-builders/update.cjs.map +1 -1
  66. package/pg-core/query-builders/update.d.cts +2 -2
  67. package/pg-core/query-builders/update.d.ts +2 -2
  68. package/pg-core/query-builders/update.js +6 -8
  69. package/pg-core/query-builders/update.js.map +1 -1
  70. package/pg-core/session.cjs.map +1 -1
  71. package/pg-core/session.d.cts +2 -1
  72. package/pg-core/session.d.ts +2 -1
  73. package/pg-core/session.js.map +1 -1
  74. package/singlestore/driver.cjs +113 -0
  75. package/singlestore/driver.cjs.map +1 -0
  76. package/singlestore/driver.d.cts +52 -0
  77. package/singlestore/driver.d.ts +52 -0
  78. package/singlestore/driver.js +89 -0
  79. package/singlestore/driver.js.map +1 -0
  80. package/singlestore/index.cjs +25 -0
  81. package/singlestore/index.cjs.map +1 -0
  82. package/singlestore/index.d.cts +2 -0
  83. package/singlestore/index.d.ts +2 -0
  84. package/singlestore/index.js +3 -0
  85. package/singlestore/index.js.map +1 -0
  86. package/singlestore/migrator.cjs +33 -0
  87. package/singlestore/migrator.cjs.map +1 -0
  88. package/singlestore/migrator.d.cts +3 -0
  89. package/singlestore/migrator.d.ts +3 -0
  90. package/singlestore/migrator.js +9 -0
  91. package/singlestore/migrator.js.map +1 -0
  92. package/singlestore/session.cjs +258 -0
  93. package/singlestore/session.cjs.map +1 -0
  94. package/singlestore/session.d.cts +52 -0
  95. package/singlestore/session.d.ts +52 -0
  96. package/singlestore/session.js +236 -0
  97. package/singlestore/session.js.map +1 -0
  98. package/singlestore-core/alias.cjs +32 -0
  99. package/singlestore-core/alias.cjs.map +1 -0
  100. package/singlestore-core/alias.d.cts +4 -0
  101. package/singlestore-core/alias.d.ts +4 -0
  102. package/singlestore-core/alias.js +8 -0
  103. package/singlestore-core/alias.js.map +1 -0
  104. package/singlestore-core/columns/all.cjs +80 -0
  105. package/singlestore-core/columns/all.cjs.map +1 -0
  106. package/singlestore-core/columns/all.d.cts +51 -0
  107. package/singlestore-core/columns/all.d.ts +51 -0
  108. package/singlestore-core/columns/all.js +56 -0
  109. package/singlestore-core/columns/all.js.map +1 -0
  110. package/singlestore-core/columns/bigint.cjs +96 -0
  111. package/singlestore-core/columns/bigint.cjs.map +1 -0
  112. package/singlestore-core/columns/bigint.d.cts +54 -0
  113. package/singlestore-core/columns/bigint.d.ts +54 -0
  114. package/singlestore-core/columns/bigint.js +68 -0
  115. package/singlestore-core/columns/bigint.js.map +1 -0
  116. package/singlestore-core/columns/binary.cjs +60 -0
  117. package/singlestore-core/columns/binary.cjs.map +1 -0
  118. package/singlestore-core/columns/binary.d.cts +28 -0
  119. package/singlestore-core/columns/binary.d.ts +28 -0
  120. package/singlestore-core/columns/binary.js +34 -0
  121. package/singlestore-core/columns/binary.js.map +1 -0
  122. package/singlestore-core/columns/boolean.cjs +62 -0
  123. package/singlestore-core/columns/boolean.cjs.map +1 -0
  124. package/singlestore-core/columns/boolean.d.cts +24 -0
  125. package/singlestore-core/columns/boolean.d.ts +24 -0
  126. package/singlestore-core/columns/boolean.js +36 -0
  127. package/singlestore-core/columns/boolean.js.map +1 -0
  128. package/singlestore-core/columns/char.cjs +62 -0
  129. package/singlestore-core/columns/char.cjs.map +1 -0
  130. package/singlestore-core/columns/char.d.cts +31 -0
  131. package/singlestore-core/columns/char.d.ts +31 -0
  132. package/singlestore-core/columns/char.js +36 -0
  133. package/singlestore-core/columns/char.js.map +1 -0
  134. package/singlestore-core/columns/common.cjs +82 -0
  135. package/singlestore-core/columns/common.cjs.map +1 -0
  136. package/singlestore-core/columns/common.d.cts +42 -0
  137. package/singlestore-core/columns/common.d.ts +42 -0
  138. package/singlestore-core/columns/common.js +55 -0
  139. package/singlestore-core/columns/common.js.map +1 -0
  140. package/singlestore-core/columns/custom.cjs +77 -0
  141. package/singlestore-core/columns/custom.cjs.map +1 -0
  142. package/singlestore-core/columns/custom.d.cts +156 -0
  143. package/singlestore-core/columns/custom.d.ts +156 -0
  144. package/singlestore-core/columns/custom.js +51 -0
  145. package/singlestore-core/columns/custom.js.map +1 -0
  146. package/singlestore-core/columns/date.cjs +93 -0
  147. package/singlestore-core/columns/date.cjs.map +1 -0
  148. package/singlestore-core/columns/date.common.cjs +48 -0
  149. package/singlestore-core/columns/date.common.cjs.map +1 -0
  150. package/singlestore-core/columns/date.common.d.cts +16 -0
  151. package/singlestore-core/columns/date.common.d.ts +16 -0
  152. package/singlestore-core/columns/date.common.js +23 -0
  153. package/singlestore-core/columns/date.common.js.map +1 -0
  154. package/singlestore-core/columns/date.d.cts +53 -0
  155. package/singlestore-core/columns/date.d.ts +53 -0
  156. package/singlestore-core/columns/date.js +65 -0
  157. package/singlestore-core/columns/date.js.map +1 -0
  158. package/singlestore-core/columns/datetime.cjs +106 -0
  159. package/singlestore-core/columns/datetime.cjs.map +1 -0
  160. package/singlestore-core/columns/datetime.d.cts +54 -0
  161. package/singlestore-core/columns/datetime.d.ts +54 -0
  162. package/singlestore-core/columns/datetime.js +78 -0
  163. package/singlestore-core/columns/datetime.js.map +1 -0
  164. package/singlestore-core/columns/decimal.cjs +76 -0
  165. package/singlestore-core/columns/decimal.cjs.map +1 -0
  166. package/singlestore-core/columns/decimal.d.cts +32 -0
  167. package/singlestore-core/columns/decimal.d.ts +32 -0
  168. package/singlestore-core/columns/decimal.js +50 -0
  169. package/singlestore-core/columns/decimal.js.map +1 -0
  170. package/singlestore-core/columns/double.cjs +72 -0
  171. package/singlestore-core/columns/double.cjs.map +1 -0
  172. package/singlestore-core/columns/double.d.cts +32 -0
  173. package/singlestore-core/columns/double.d.ts +32 -0
  174. package/singlestore-core/columns/double.js +46 -0
  175. package/singlestore-core/columns/double.js.map +1 -0
  176. package/singlestore-core/columns/enum.cjs +67 -0
  177. package/singlestore-core/columns/enum.cjs.map +1 -0
  178. package/singlestore-core/columns/enum.d.cts +31 -0
  179. package/singlestore-core/columns/enum.d.ts +31 -0
  180. package/singlestore-core/columns/enum.js +41 -0
  181. package/singlestore-core/columns/enum.js.map +1 -0
  182. package/singlestore-core/columns/float.cjs +72 -0
  183. package/singlestore-core/columns/float.cjs.map +1 -0
  184. package/singlestore-core/columns/float.d.cts +32 -0
  185. package/singlestore-core/columns/float.d.ts +32 -0
  186. package/singlestore-core/columns/float.js +46 -0
  187. package/singlestore-core/columns/float.js.map +1 -0
  188. package/singlestore-core/columns/index.cjs +71 -0
  189. package/singlestore-core/columns/index.cjs.map +1 -0
  190. package/singlestore-core/columns/index.d.cts +25 -0
  191. package/singlestore-core/columns/index.d.ts +25 -0
  192. package/singlestore-core/columns/index.js +26 -0
  193. package/singlestore-core/columns/index.js.map +1 -0
  194. package/singlestore-core/columns/int.cjs +65 -0
  195. package/singlestore-core/columns/int.cjs.map +1 -0
  196. package/singlestore-core/columns/int.d.cts +28 -0
  197. package/singlestore-core/columns/int.d.ts +28 -0
  198. package/singlestore-core/columns/int.js +39 -0
  199. package/singlestore-core/columns/int.js.map +1 -0
  200. package/singlestore-core/columns/json.cjs +59 -0
  201. package/singlestore-core/columns/json.cjs.map +1 -0
  202. package/singlestore-core/columns/json.d.cts +24 -0
  203. package/singlestore-core/columns/json.d.ts +24 -0
  204. package/singlestore-core/columns/json.js +33 -0
  205. package/singlestore-core/columns/json.js.map +1 -0
  206. package/singlestore-core/columns/mediumint.cjs +65 -0
  207. package/singlestore-core/columns/mediumint.cjs.map +1 -0
  208. package/singlestore-core/columns/mediumint.d.cts +26 -0
  209. package/singlestore-core/columns/mediumint.d.ts +26 -0
  210. package/singlestore-core/columns/mediumint.js +39 -0
  211. package/singlestore-core/columns/mediumint.js.map +1 -0
  212. package/singlestore-core/columns/real.cjs +68 -0
  213. package/singlestore-core/columns/real.cjs.map +1 -0
  214. package/singlestore-core/columns/real.d.cts +30 -0
  215. package/singlestore-core/columns/real.d.ts +30 -0
  216. package/singlestore-core/columns/real.js +42 -0
  217. package/singlestore-core/columns/real.js.map +1 -0
  218. package/singlestore-core/columns/serial.cjs +64 -0
  219. package/singlestore-core/columns/serial.cjs.map +1 -0
  220. package/singlestore-core/columns/serial.d.cts +24 -0
  221. package/singlestore-core/columns/serial.d.ts +24 -0
  222. package/singlestore-core/columns/serial.js +38 -0
  223. package/singlestore-core/columns/serial.js.map +1 -0
  224. package/singlestore-core/columns/smallint.cjs +65 -0
  225. package/singlestore-core/columns/smallint.cjs.map +1 -0
  226. package/singlestore-core/columns/smallint.d.cts +26 -0
  227. package/singlestore-core/columns/smallint.d.ts +26 -0
  228. package/singlestore-core/columns/smallint.js +39 -0
  229. package/singlestore-core/columns/smallint.js.map +1 -0
  230. package/singlestore-core/columns/text.cjs +80 -0
  231. package/singlestore-core/columns/text.cjs.map +1 -0
  232. package/singlestore-core/columns/text.d.cts +46 -0
  233. package/singlestore-core/columns/text.d.ts +46 -0
  234. package/singlestore-core/columns/text.js +51 -0
  235. package/singlestore-core/columns/text.js.map +1 -0
  236. package/singlestore-core/columns/time.cjs +56 -0
  237. package/singlestore-core/columns/time.cjs.map +1 -0
  238. package/singlestore-core/columns/time.d.cts +23 -0
  239. package/singlestore-core/columns/time.d.ts +23 -0
  240. package/singlestore-core/columns/time.js +30 -0
  241. package/singlestore-core/columns/time.js.map +1 -0
  242. package/singlestore-core/columns/timestamp.cjs +97 -0
  243. package/singlestore-core/columns/timestamp.cjs.map +1 -0
  244. package/singlestore-core/columns/timestamp.d.cts +49 -0
  245. package/singlestore-core/columns/timestamp.d.ts +49 -0
  246. package/singlestore-core/columns/timestamp.js +69 -0
  247. package/singlestore-core/columns/timestamp.js.map +1 -0
  248. package/singlestore-core/columns/tinyint.cjs +65 -0
  249. package/singlestore-core/columns/tinyint.cjs.map +1 -0
  250. package/singlestore-core/columns/tinyint.d.cts +26 -0
  251. package/singlestore-core/columns/tinyint.d.ts +26 -0
  252. package/singlestore-core/columns/tinyint.js +39 -0
  253. package/singlestore-core/columns/tinyint.js.map +1 -0
  254. package/singlestore-core/columns/varbinary.cjs +61 -0
  255. package/singlestore-core/columns/varbinary.cjs.map +1 -0
  256. package/singlestore-core/columns/varbinary.d.cts +26 -0
  257. package/singlestore-core/columns/varbinary.d.ts +26 -0
  258. package/singlestore-core/columns/varbinary.js +35 -0
  259. package/singlestore-core/columns/varbinary.js.map +1 -0
  260. package/singlestore-core/columns/varchar.cjs +63 -0
  261. package/singlestore-core/columns/varchar.cjs.map +1 -0
  262. package/singlestore-core/columns/varchar.d.cts +29 -0
  263. package/singlestore-core/columns/varchar.d.ts +29 -0
  264. package/singlestore-core/columns/varchar.js +37 -0
  265. package/singlestore-core/columns/varchar.js.map +1 -0
  266. package/singlestore-core/columns/year.cjs +56 -0
  267. package/singlestore-core/columns/year.cjs.map +1 -0
  268. package/singlestore-core/columns/year.d.cts +23 -0
  269. package/singlestore-core/columns/year.d.ts +23 -0
  270. package/singlestore-core/columns/year.js +30 -0
  271. package/singlestore-core/columns/year.js.map +1 -0
  272. package/singlestore-core/db.cjs +261 -0
  273. package/singlestore-core/db.cjs.map +1 -0
  274. package/singlestore-core/db.d.cts +231 -0
  275. package/singlestore-core/db.d.ts +231 -0
  276. package/singlestore-core/db.js +242 -0
  277. package/singlestore-core/db.js.map +1 -0
  278. package/singlestore-core/dialect.cjs +607 -0
  279. package/singlestore-core/dialect.cjs.map +1 -0
  280. package/singlestore-core/dialect.d.cts +64 -0
  281. package/singlestore-core/dialect.d.ts +64 -0
  282. package/singlestore-core/dialect.js +589 -0
  283. package/singlestore-core/dialect.js.map +1 -0
  284. package/singlestore-core/expressions.cjs +49 -0
  285. package/singlestore-core/expressions.cjs.map +1 -0
  286. package/singlestore-core/expressions.d.cts +8 -0
  287. package/singlestore-core/expressions.d.ts +8 -0
  288. package/singlestore-core/expressions.js +22 -0
  289. package/singlestore-core/expressions.js.map +1 -0
  290. package/singlestore-core/index.cjs +47 -0
  291. package/singlestore-core/index.cjs.map +1 -0
  292. package/singlestore-core/index.d.cts +13 -0
  293. package/singlestore-core/index.d.ts +13 -0
  294. package/singlestore-core/index.js +14 -0
  295. package/singlestore-core/index.js.map +1 -0
  296. package/singlestore-core/indexes.cjs +88 -0
  297. package/singlestore-core/indexes.cjs.map +1 -0
  298. package/singlestore-core/indexes.d.cts +62 -0
  299. package/singlestore-core/indexes.d.ts +62 -0
  300. package/singlestore-core/indexes.js +60 -0
  301. package/singlestore-core/indexes.js.map +1 -0
  302. package/singlestore-core/primary-keys.cjs +68 -0
  303. package/singlestore-core/primary-keys.cjs.map +1 -0
  304. package/singlestore-core/primary-keys.d.cts +30 -0
  305. package/singlestore-core/primary-keys.d.ts +30 -0
  306. package/singlestore-core/primary-keys.js +42 -0
  307. package/singlestore-core/primary-keys.js.map +1 -0
  308. package/singlestore-core/query-builders/count.cjs +73 -0
  309. package/singlestore-core/query-builders/count.cjs.map +1 -0
  310. package/singlestore-core/query-builders/count.d.cts +25 -0
  311. package/singlestore-core/query-builders/count.d.ts +25 -0
  312. package/singlestore-core/query-builders/count.js +49 -0
  313. package/singlestore-core/query-builders/count.js.map +1 -0
  314. package/singlestore-core/query-builders/delete.cjs +123 -0
  315. package/singlestore-core/query-builders/delete.cjs.map +1 -0
  316. package/singlestore-core/query-builders/delete.d.cts +83 -0
  317. package/singlestore-core/query-builders/delete.d.ts +83 -0
  318. package/singlestore-core/query-builders/delete.js +99 -0
  319. package/singlestore-core/query-builders/delete.js.map +1 -0
  320. package/singlestore-core/query-builders/index.cjs +33 -0
  321. package/singlestore-core/query-builders/index.cjs.map +1 -0
  322. package/singlestore-core/query-builders/index.d.cts +6 -0
  323. package/singlestore-core/query-builders/index.d.ts +6 -0
  324. package/singlestore-core/query-builders/index.js +7 -0
  325. package/singlestore-core/query-builders/index.js.map +1 -0
  326. package/singlestore-core/query-builders/insert.cjs +146 -0
  327. package/singlestore-core/query-builders/insert.cjs.map +1 -0
  328. package/singlestore-core/query-builders/insert.d.cts +106 -0
  329. package/singlestore-core/query-builders/insert.d.ts +106 -0
  330. package/singlestore-core/query-builders/insert.js +121 -0
  331. package/singlestore-core/query-builders/insert.js.map +1 -0
  332. package/singlestore-core/query-builders/query-builder.cjs +99 -0
  333. package/singlestore-core/query-builders/query-builder.cjs.map +1 -0
  334. package/singlestore-core/query-builders/query-builder.d.cts +33 -0
  335. package/singlestore-core/query-builders/query-builder.d.ts +33 -0
  336. package/singlestore-core/query-builders/query-builder.js +75 -0
  337. package/singlestore-core/query-builders/query-builder.js.map +1 -0
  338. package/singlestore-core/query-builders/query.cjs +126 -0
  339. package/singlestore-core/query-builders/query.cjs.map +1 -0
  340. package/singlestore-core/query-builders/query.d.cts +42 -0
  341. package/singlestore-core/query-builders/query.d.ts +42 -0
  342. package/singlestore-core/query-builders/query.js +103 -0
  343. package/singlestore-core/query-builders/query.js.map +1 -0
  344. package/singlestore-core/query-builders/select.cjs +687 -0
  345. package/singlestore-core/query-builders/select.cjs.map +1 -0
  346. package/singlestore-core/query-builders/select.d.cts +585 -0
  347. package/singlestore-core/query-builders/select.d.ts +585 -0
  348. package/singlestore-core/query-builders/select.js +662 -0
  349. package/singlestore-core/query-builders/select.js.map +1 -0
  350. package/singlestore-core/query-builders/select.types.cjs +17 -0
  351. package/singlestore-core/query-builders/select.types.cjs.map +1 -0
  352. package/singlestore-core/query-builders/select.types.d.cts +137 -0
  353. package/singlestore-core/query-builders/select.types.d.ts +137 -0
  354. package/singlestore-core/query-builders/select.types.js +1 -0
  355. package/singlestore-core/query-builders/select.types.js.map +1 -0
  356. package/singlestore-core/query-builders/update.cjs +147 -0
  357. package/singlestore-core/query-builders/update.cjs.map +1 -0
  358. package/singlestore-core/query-builders/update.d.cts +102 -0
  359. package/singlestore-core/query-builders/update.d.ts +102 -0
  360. package/singlestore-core/query-builders/update.js +122 -0
  361. package/singlestore-core/query-builders/update.js.map +1 -0
  362. package/singlestore-core/schema.cjs +56 -0
  363. package/singlestore-core/schema.cjs.map +1 -0
  364. package/singlestore-core/schema.d.cts +22 -0
  365. package/singlestore-core/schema.d.ts +22 -0
  366. package/singlestore-core/schema.js +29 -0
  367. package/singlestore-core/schema.js.map +1 -0
  368. package/singlestore-core/session.cjs +87 -0
  369. package/singlestore-core/session.cjs.map +1 -0
  370. package/singlestore-core/session.d.cts +66 -0
  371. package/singlestore-core/session.d.ts +66 -0
  372. package/singlestore-core/session.js +61 -0
  373. package/singlestore-core/session.js.map +1 -0
  374. package/singlestore-core/subquery.cjs +17 -0
  375. package/singlestore-core/subquery.cjs.map +1 -0
  376. package/singlestore-core/subquery.d.cts +5 -0
  377. package/singlestore-core/subquery.d.ts +5 -0
  378. package/singlestore-core/subquery.js +1 -0
  379. package/singlestore-core/subquery.js.map +1 -0
  380. package/singlestore-core/table.cjs +73 -0
  381. package/singlestore-core/table.cjs.map +1 -0
  382. package/singlestore-core/table.d.cts +40 -0
  383. package/singlestore-core/table.d.ts +40 -0
  384. package/singlestore-core/table.js +46 -0
  385. package/singlestore-core/table.js.map +1 -0
  386. package/singlestore-core/unique-constraint.cjs +82 -0
  387. package/singlestore-core/unique-constraint.cjs.map +1 -0
  388. package/singlestore-core/unique-constraint.d.cts +24 -0
  389. package/singlestore-core/unique-constraint.d.ts +24 -0
  390. package/singlestore-core/unique-constraint.js +54 -0
  391. package/singlestore-core/unique-constraint.js.map +1 -0
  392. package/singlestore-core/utils.cjs +65 -0
  393. package/singlestore-core/utils.cjs.map +1 -0
  394. package/singlestore-core/utils.d.cts +13 -0
  395. package/singlestore-core/utils.d.ts +13 -0
  396. package/singlestore-core/utils.js +41 -0
  397. package/singlestore-core/utils.js.map +1 -0
  398. package/singlestore-core/view-base.cjs +33 -0
  399. package/singlestore-core/view-base.cjs.map +1 -0
  400. package/singlestore-core/view-base.d.cts +9 -0
  401. package/singlestore-core/view-base.d.ts +9 -0
  402. package/singlestore-core/view-base.js +9 -0
  403. package/singlestore-core/view-base.js.map +1 -0
  404. package/singlestore-core/view-common.cjs +29 -0
  405. package/singlestore-core/view-common.cjs.map +1 -0
  406. package/singlestore-core/view-common.d.cts +1 -0
  407. package/singlestore-core/view-common.d.ts +1 -0
  408. package/singlestore-core/view-common.js +5 -0
  409. package/singlestore-core/view-common.js.map +1 -0
  410. package/singlestore-core/view.cjs +146 -0
  411. package/singlestore-core/view.cjs.map +1 -0
  412. package/singlestore-core/view.d.cts +65 -0
  413. package/singlestore-core/view.d.ts +65 -0
  414. package/singlestore-core/view.js +119 -0
  415. package/singlestore-core/view.js.map +1 -0
  416. package/singlestore-proxy/driver.cjs +62 -0
  417. package/singlestore-proxy/driver.cjs.map +1 -0
  418. package/singlestore-proxy/driver.d.cts +13 -0
  419. package/singlestore-proxy/driver.d.ts +13 -0
  420. package/singlestore-proxy/driver.js +42 -0
  421. package/singlestore-proxy/driver.js.map +1 -0
  422. package/singlestore-proxy/index.cjs +25 -0
  423. package/singlestore-proxy/index.cjs.map +1 -0
  424. package/singlestore-proxy/index.d.cts +2 -0
  425. package/singlestore-proxy/index.d.ts +2 -0
  426. package/singlestore-proxy/index.js +3 -0
  427. package/singlestore-proxy/index.js.map +1 -0
  428. package/singlestore-proxy/migrator.cjs +60 -0
  429. package/singlestore-proxy/migrator.cjs.map +1 -0
  430. package/singlestore-proxy/migrator.d.cts +4 -0
  431. package/singlestore-proxy/migrator.d.ts +4 -0
  432. package/singlestore-proxy/migrator.js +36 -0
  433. package/singlestore-proxy/migrator.js.map +1 -0
  434. package/singlestore-proxy/session.cjs +127 -0
  435. package/singlestore-proxy/session.cjs.map +1 -0
  436. package/singlestore-proxy/session.d.cts +50 -0
  437. package/singlestore-proxy/session.d.ts +50 -0
  438. package/singlestore-proxy/session.js +101 -0
  439. package/singlestore-proxy/session.js.map +1 -0
  440. package/sqlite-core/columns/blob.cjs +16 -2
  441. package/sqlite-core/columns/blob.cjs.map +1 -1
  442. package/sqlite-core/columns/blob.d.cts +2 -2
  443. package/sqlite-core/columns/blob.d.ts +2 -2
  444. package/sqlite-core/columns/blob.js +16 -2
  445. package/sqlite-core/columns/blob.js.map +1 -1
  446. package/utils.cjs.map +1 -1
  447. package/utils.d.cts +1 -0
  448. package/utils.d.ts +1 -0
  449. package/utils.js.map +1 -1
  450. package/version.cjs +1 -1
  451. package/version.d.cts +1 -1
  452. package/version.d.ts +1 -1
  453. package/version.js +1 -1
@@ -0,0 +1,242 @@
1
+ import { entityKind } from "../entity.js";
2
+ import { SelectionProxyHandler } from "../selection-proxy.js";
3
+ import { sql } from "../sql/sql.js";
4
+ import { WithSubquery } from "../subquery.js";
5
+ import { SingleStoreCountBuilder } from "./query-builders/count.js";
6
+ import {
7
+ QueryBuilder,
8
+ SingleStoreDeleteBase,
9
+ SingleStoreInsertBuilder,
10
+ SingleStoreSelectBuilder,
11
+ SingleStoreUpdateBuilder
12
+ } from "./query-builders/index.js";
13
+ class SingleStoreDatabase {
14
+ constructor(dialect, session, schema) {
15
+ this.dialect = dialect;
16
+ this.session = session;
17
+ this._ = schema ? {
18
+ schema: schema.schema,
19
+ fullSchema: schema.fullSchema,
20
+ tableNamesMap: schema.tableNamesMap
21
+ } : {
22
+ schema: void 0,
23
+ fullSchema: {},
24
+ tableNamesMap: {}
25
+ };
26
+ this.query = {};
27
+ }
28
+ static [entityKind] = "SingleStoreDatabase";
29
+ // We are waiting for SingleStore support for `json_array` function
30
+ /**@inrernal */
31
+ query;
32
+ /**
33
+ * Creates a subquery that defines a temporary named result set as a CTE.
34
+ *
35
+ * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
36
+ *
37
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
38
+ *
39
+ * @param alias The alias for the subquery.
40
+ *
41
+ * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
42
+ *
43
+ * @example
44
+ *
45
+ * ```ts
46
+ * // Create a subquery with alias 'sq' and use it in the select query
47
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
48
+ *
49
+ * const result = await db.with(sq).select().from(sq);
50
+ * ```
51
+ *
52
+ * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
53
+ *
54
+ * ```ts
55
+ * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
56
+ * const sq = db.$with('sq').as(db.select({
57
+ * name: sql<string>`upper(${users.name})`.as('name'),
58
+ * })
59
+ * .from(users));
60
+ *
61
+ * const result = await db.with(sq).select({ name: sq.name }).from(sq);
62
+ * ```
63
+ */
64
+ $with(alias) {
65
+ const self = this;
66
+ return {
67
+ as(qb) {
68
+ if (typeof qb === "function") {
69
+ qb = qb(new QueryBuilder(self.dialect));
70
+ }
71
+ return new Proxy(
72
+ new WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true),
73
+ new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
74
+ );
75
+ }
76
+ };
77
+ }
78
+ $count(source, filters) {
79
+ return new SingleStoreCountBuilder({ source, filters, session: this.session });
80
+ }
81
+ /**
82
+ * Incorporates a previously defined CTE (using `$with`) into the main query.
83
+ *
84
+ * This method allows the main query to reference a temporary named result set.
85
+ *
86
+ * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
87
+ *
88
+ * @param queries The CTEs to incorporate into the main query.
89
+ *
90
+ * @example
91
+ *
92
+ * ```ts
93
+ * // Define a subquery 'sq' as a CTE using $with
94
+ * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
95
+ *
96
+ * // Incorporate the CTE 'sq' into the main query and select from it
97
+ * const result = await db.with(sq).select().from(sq);
98
+ * ```
99
+ */
100
+ with(...queries) {
101
+ const self = this;
102
+ function select(fields) {
103
+ return new SingleStoreSelectBuilder({
104
+ fields: fields ?? void 0,
105
+ session: self.session,
106
+ dialect: self.dialect,
107
+ withList: queries
108
+ });
109
+ }
110
+ function selectDistinct(fields) {
111
+ return new SingleStoreSelectBuilder({
112
+ fields: fields ?? void 0,
113
+ session: self.session,
114
+ dialect: self.dialect,
115
+ withList: queries,
116
+ distinct: true
117
+ });
118
+ }
119
+ function update(table) {
120
+ return new SingleStoreUpdateBuilder(table, self.session, self.dialect, queries);
121
+ }
122
+ function delete_(table) {
123
+ return new SingleStoreDeleteBase(table, self.session, self.dialect, queries);
124
+ }
125
+ return { select, selectDistinct, update, delete: delete_ };
126
+ }
127
+ select(fields) {
128
+ return new SingleStoreSelectBuilder({ fields: fields ?? void 0, session: this.session, dialect: this.dialect });
129
+ }
130
+ selectDistinct(fields) {
131
+ return new SingleStoreSelectBuilder({
132
+ fields: fields ?? void 0,
133
+ session: this.session,
134
+ dialect: this.dialect,
135
+ distinct: true
136
+ });
137
+ }
138
+ /**
139
+ * Creates an update query.
140
+ *
141
+ * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
142
+ *
143
+ * Use `.set()` method to specify which values to update.
144
+ *
145
+ * See docs: {@link https://orm.drizzle.team/docs/update}
146
+ *
147
+ * @param table The table to update.
148
+ *
149
+ * @example
150
+ *
151
+ * ```ts
152
+ * // Update all rows in the 'cars' table
153
+ * await db.update(cars).set({ color: 'red' });
154
+ *
155
+ * // Update rows with filters and conditions
156
+ * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
157
+ * ```
158
+ */
159
+ update(table) {
160
+ return new SingleStoreUpdateBuilder(table, this.session, this.dialect);
161
+ }
162
+ /**
163
+ * Creates an insert query.
164
+ *
165
+ * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
166
+ *
167
+ * See docs: {@link https://orm.drizzle.team/docs/insert}
168
+ *
169
+ * @param table The table to insert into.
170
+ *
171
+ * @example
172
+ *
173
+ * ```ts
174
+ * // Insert one row
175
+ * await db.insert(cars).values({ brand: 'BMW' });
176
+ *
177
+ * // Insert multiple rows
178
+ * await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
179
+ * ```
180
+ */
181
+ insert(table) {
182
+ return new SingleStoreInsertBuilder(table, this.session, this.dialect);
183
+ }
184
+ /**
185
+ * Creates a delete query.
186
+ *
187
+ * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
188
+ *
189
+ * See docs: {@link https://orm.drizzle.team/docs/delete}
190
+ *
191
+ * @param table The table to delete from.
192
+ *
193
+ * @example
194
+ *
195
+ * ```ts
196
+ * // Delete all rows in the 'cars' table
197
+ * await db.delete(cars);
198
+ *
199
+ * // Delete rows with filters and conditions
200
+ * await db.delete(cars).where(eq(cars.color, 'green'));
201
+ * ```
202
+ */
203
+ delete(table) {
204
+ return new SingleStoreDeleteBase(table, this.session, this.dialect);
205
+ }
206
+ execute(query) {
207
+ return this.session.execute(typeof query === "string" ? sql.raw(query) : query.getSQL());
208
+ }
209
+ transaction(transaction, config) {
210
+ return this.session.transaction(transaction, config);
211
+ }
212
+ }
213
+ const withReplicas = (primary, replicas, getReplica = () => replicas[Math.floor(Math.random() * replicas.length)]) => {
214
+ const select = (...args) => getReplica(replicas).select(...args);
215
+ const selectDistinct = (...args) => getReplica(replicas).selectDistinct(...args);
216
+ const $with = (...args) => getReplica(replicas).with(...args);
217
+ const update = (...args) => primary.update(...args);
218
+ const insert = (...args) => primary.insert(...args);
219
+ const $delete = (...args) => primary.delete(...args);
220
+ const execute = (...args) => primary.execute(...args);
221
+ const transaction = (...args) => primary.transaction(...args);
222
+ return {
223
+ ...primary,
224
+ update,
225
+ insert,
226
+ delete: $delete,
227
+ execute,
228
+ transaction,
229
+ $primary: primary,
230
+ select,
231
+ selectDistinct,
232
+ with: $with,
233
+ get query() {
234
+ return getReplica(replicas).query;
235
+ }
236
+ };
237
+ };
238
+ export {
239
+ SingleStoreDatabase,
240
+ withReplicas
241
+ };
242
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/singlestore-core/db.ts"],"sourcesContent":["import type { ResultSetHeader } from 'mysql2/promise';\nimport { entityKind } from '~/entity.ts';\nimport type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { ExtractTablesWithRelations, RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { SingleStoreDriverDatabase } from '~/singlestore/driver.ts';\nimport { type ColumnsSelection, type SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport { WithSubquery } from '~/subquery.ts';\nimport type { SingleStoreDialect } from './dialect.ts';\nimport { SingleStoreCountBuilder } from './query-builders/count.ts';\nimport {\n\tQueryBuilder,\n\tSingleStoreDeleteBase,\n\tSingleStoreInsertBuilder,\n\tSingleStoreSelectBuilder,\n\tSingleStoreUpdateBuilder,\n} from './query-builders/index.ts';\nimport type { SelectedFields } from './query-builders/select.types.ts';\nimport type {\n\tPreparedQueryHKTBase,\n\tSingleStoreQueryResultHKT,\n\tSingleStoreQueryResultKind,\n\tSingleStoreSession,\n\tSingleStoreTransaction,\n\tSingleStoreTransactionConfig,\n} from './session.ts';\nimport type { WithSubqueryWithSelection } from './subquery.ts';\nimport type { SingleStoreTable } from './table.ts';\n\nexport class SingleStoreDatabase<\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = {},\n\tTSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>,\n> {\n\tstatic readonly [entityKind]: string = 'SingleStoreDatabase';\n\n\tdeclare readonly _: {\n\t\treadonly schema: TSchema | undefined;\n\t\treadonly fullSchema: TFullSchema;\n\t\treadonly tableNamesMap: Record<string, string>;\n\t};\n\n\t// We are waiting for SingleStore support for `json_array` function\n\t/**@inrernal */\n\tquery: unknown;\n\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly dialect: SingleStoreDialect,\n\t\t/** @internal */\n\t\treadonly session: SingleStoreSession<any, any, any, any>,\n\t\tschema: RelationalSchemaConfig<TSchema> | undefined,\n\t) {\n\t\tthis._ = schema\n\t\t\t? {\n\t\t\t\tschema: schema.schema,\n\t\t\t\tfullSchema: schema.fullSchema as TFullSchema,\n\t\t\t\ttableNamesMap: schema.tableNamesMap,\n\t\t\t}\n\t\t\t: {\n\t\t\t\tschema: undefined,\n\t\t\t\tfullSchema: {} as TFullSchema,\n\t\t\t\ttableNamesMap: {},\n\t\t\t};\n\t\tthis.query = {} as typeof this['query'];\n\t\t// this.queryNotSupported = true;\n\t\t// if (this._.schema) {\n\t\t// \tfor (const [tableName, columns] of Object.entries(this._.schema)) {\n\t\t// \t\t(this.query as SingleStoreDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =\n\t\t// \t\t\tnew RelationalQueryBuilder(\n\t\t// \t\t\t\tschema!.fullSchema,\n\t\t// \t\t\t\tthis._.schema,\n\t\t// \t\t\t\tthis._.tableNamesMap,\n\t\t// \t\t\t\tschema!.fullSchema[tableName] as SingleStoreTable,\n\t\t// \t\t\t\tcolumns,\n\t\t// \t\t\t\tdialect,\n\t\t// \t\t\t\tsession,\n\t\t// \t\t\t);\n\t\t// \t}\n\t\t// }\n\t}\n\n\t/**\n\t * Creates a subquery that defines a temporary named result set as a CTE.\n\t *\n\t * It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param alias The alias for the subquery.\n\t *\n\t * Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Create a subquery with alias 'sq' and use it in the select query\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t *\n\t * To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:\n\t *\n\t * ```ts\n\t * // Select an arbitrary SQL value as a field in a CTE and reference it in the main query\n\t * const sq = db.$with('sq').as(db.select({\n\t * name: sql<string>`upper(${users.name})`.as('name'),\n\t * })\n\t * .from(users));\n\t *\n\t * const result = await db.with(sq).select({ name: sq.name }).from(sq);\n\t * ```\n\t */\n\t$with<TAlias extends string>(alias: TAlias) {\n\t\tconst self = this;\n\t\treturn {\n\t\t\tas<TSelection extends ColumnsSelection>(\n\t\t\t\tqb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),\n\t\t\t): WithSubqueryWithSelection<TSelection, TAlias> {\n\t\t\t\tif (typeof qb === 'function') {\n\t\t\t\t\tqb = qb(new QueryBuilder(self.dialect));\n\t\t\t\t}\n\n\t\t\t\treturn new Proxy(\n\t\t\t\t\tnew WithSubquery(qb.getSQL(), qb.getSelectedFields() as SelectedFields, alias, true),\n\t\t\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t\t\t) as WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t},\n\t\t};\n\t}\n\n\t$count(\n\t\tsource: SingleStoreTable | SQL | SQLWrapper, // SingleStoreViewBase |\n\t\tfilters?: SQL<unknown>,\n\t) {\n\t\treturn new SingleStoreCountBuilder({ source, filters, session: this.session });\n\t}\n\n\t/**\n\t * Incorporates a previously defined CTE (using `$with`) into the main query.\n\t *\n\t * This method allows the main query to reference a temporary named result set.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#with-clause}\n\t *\n\t * @param queries The CTEs to incorporate into the main query.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Define a subquery 'sq' as a CTE using $with\n\t * const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));\n\t *\n\t * // Incorporate the CTE 'sq' into the main query and select from it\n\t * const result = await db.with(sq).select().from(sq);\n\t * ```\n\t */\n\twith(...queries: WithSubquery[]) {\n\t\tconst self = this;\n\n\t\t/**\n\t\t * Creates a select query.\n\t\t *\n\t\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Select all columns and all rows from the 'cars' table\n\t\t * const allCars: Car[] = await db.select().from(cars);\n\t\t *\n\t\t * // Select specific columns and all rows from the 'cars' table\n\t\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * brand: cars.brand\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t *\n\t\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t\t *\n\t\t * ```ts\n\t\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t\t * id: cars.id,\n\t\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t\t * })\n\t\t * .from(cars);\n\t\t * ```\n\t\t */\n\t\tfunction select(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction select<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction select(fields?: SelectedFields): SingleStoreSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new SingleStoreSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Adds `distinct` expression to the select query.\n\t\t *\n\t\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t\t *\n\t\t * Use `.from()` method to specify which table to select from.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t\t *\n\t\t * @param fields The selection object.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * // Select all unique rows from the 'cars' table\n\t\t * await db.selectDistinct()\n\t\t * .from(cars)\n\t\t * .orderBy(cars.id, cars.brand, cars.color);\n\t\t *\n\t\t * // Select all unique brands from the 'cars' table\n\t\t * await db.selectDistinct({ brand: cars.brand })\n\t\t * .from(cars)\n\t\t * .orderBy(cars.brand);\n\t\t * ```\n\t\t */\n\t\tfunction selectDistinct(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;\n\t\tfunction selectDistinct<TSelection extends SelectedFields>(\n\t\t\tfields: TSelection,\n\t\t): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;\n\t\tfunction selectDistinct(\n\t\t\tfields?: SelectedFields,\n\t\t): SingleStoreSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\t\treturn new SingleStoreSelectBuilder({\n\t\t\t\tfields: fields ?? undefined,\n\t\t\t\tsession: self.session,\n\t\t\t\tdialect: self.dialect,\n\t\t\t\twithList: queries,\n\t\t\t\tdistinct: true,\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Creates an update query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t\t *\n\t\t * Use `.set()` method to specify which values to update.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t\t *\n\t\t * @param table The table to update.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Update all rows in the 'cars' table\n\t\t * await db.update(cars).set({ color: 'red' });\n\t\t *\n\t\t * // Update rows with filters and conditions\n\t\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t\t * ```\n\t\t */\n\t\tfunction update<TTable extends SingleStoreTable>(\n\t\t\ttable: TTable,\n\t\t): SingleStoreUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new SingleStoreUpdateBuilder(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\t/**\n\t\t * Creates a delete query.\n\t\t *\n\t\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t\t *\n\t\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t\t *\n\t\t * @param table The table to delete from.\n\t\t *\n\t\t * @example\n\t\t *\n\t\t * ```ts\n\t\t * // Delete all rows in the 'cars' table\n\t\t * await db.delete(cars);\n\t\t *\n\t\t * // Delete rows with filters and conditions\n\t\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t\t * ```\n\t\t */\n\t\tfunction delete_<TTable extends SingleStoreTable>(\n\t\t\ttable: TTable,\n\t\t): SingleStoreDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\t\treturn new SingleStoreDeleteBase(table, self.session, self.dialect, queries);\n\t\t}\n\n\t\treturn { select, selectDistinct, update, delete: delete_ };\n\t}\n\n\t/**\n\t * Creates a select query.\n\t *\n\t * Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all columns and all rows from the 'cars' table\n\t * const allCars: Car[] = await db.select().from(cars);\n\t *\n\t * // Select specific columns and all rows from the 'cars' table\n\t * const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({\n\t * id: cars.id,\n\t * brand: cars.brand\n\t * })\n\t * .from(cars);\n\t * ```\n\t *\n\t * Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:\n\t *\n\t * ```ts\n\t * // Select specific columns along with expression and all rows from the 'cars' table\n\t * const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({\n\t * id: cars.id,\n\t * lowerBrand: sql<string>`lower(${cars.brand})`,\n\t * })\n\t * .from(cars);\n\t * ```\n\t */\n\tselect(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselect<TSelection extends SelectedFields>(\n\t\tfields: TSelection,\n\t): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselect(fields?: SelectedFields): SingleStoreSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new SingleStoreSelectBuilder({ fields: fields ?? undefined, session: this.session, dialect: this.dialect });\n\t}\n\n\t/**\n\t * Adds `distinct` expression to the select query.\n\t *\n\t * Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.\n\t *\n\t * Use `.from()` method to specify which table to select from.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#distinct}\n\t *\n\t * @param fields The selection object.\n\t *\n\t * @example\n\t * ```ts\n\t * // Select all unique rows from the 'cars' table\n\t * await db.selectDistinct()\n\t * .from(cars)\n\t * .orderBy(cars.id, cars.brand, cars.color);\n\t *\n\t * // Select all unique brands from the 'cars' table\n\t * await db.selectDistinct({ brand: cars.brand })\n\t * .from(cars)\n\t * .orderBy(cars.brand);\n\t * ```\n\t */\n\tselectDistinct(): SingleStoreSelectBuilder<undefined, TPreparedQueryHKT>;\n\tselectDistinct<TSelection extends SelectedFields>(\n\t\tfields: TSelection,\n\t): SingleStoreSelectBuilder<TSelection, TPreparedQueryHKT>;\n\tselectDistinct(fields?: SelectedFields): SingleStoreSelectBuilder<SelectedFields | undefined, TPreparedQueryHKT> {\n\t\treturn new SingleStoreSelectBuilder({\n\t\t\tfields: fields ?? undefined,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\tdistinct: true,\n\t\t});\n\t}\n\n\t/**\n\t * Creates an update query.\n\t *\n\t * Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.\n\t *\n\t * Use `.set()` method to specify which values to update.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param table The table to update.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Update all rows in the 'cars' table\n\t * await db.update(cars).set({ color: 'red' });\n\t *\n\t * // Update rows with filters and conditions\n\t * await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));\n\t * ```\n\t */\n\tupdate<TTable extends SingleStoreTable>(\n\t\ttable: TTable,\n\t): SingleStoreUpdateBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new SingleStoreUpdateBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates an insert query.\n\t *\n\t * Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/insert}\n\t *\n\t * @param table The table to insert into.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Insert one row\n\t * await db.insert(cars).values({ brand: 'BMW' });\n\t *\n\t * // Insert multiple rows\n\t * await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);\n\t * ```\n\t */\n\tinsert<TTable extends SingleStoreTable>(\n\t\ttable: TTable,\n\t): SingleStoreInsertBuilder<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new SingleStoreInsertBuilder(table, this.session, this.dialect);\n\t}\n\n\t/**\n\t * Creates a delete query.\n\t *\n\t * Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/delete}\n\t *\n\t * @param table The table to delete from.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Delete all rows in the 'cars' table\n\t * await db.delete(cars);\n\t *\n\t * // Delete rows with filters and conditions\n\t * await db.delete(cars).where(eq(cars.color, 'green'));\n\t * ```\n\t */\n\tdelete<TTable extends SingleStoreTable>(\n\t\ttable: TTable,\n\t): SingleStoreDeleteBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new SingleStoreDeleteBase(table, this.session, this.dialect);\n\t}\n\n\texecute<T extends { [column: string]: any } = ResultSetHeader>(\n\t\tquery: SQLWrapper | string,\n\t): Promise<SingleStoreQueryResultKind<TQueryResult, T>> {\n\t\treturn this.session.execute(typeof query === 'string' ? sql.raw(query) : query.getSQL());\n\t}\n\n\ttransaction<T>(\n\t\ttransaction: (\n\t\t\ttx: SingleStoreTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>,\n\t\t\tconfig?: SingleStoreTransactionConfig,\n\t\t) => Promise<T>,\n\t\tconfig?: SingleStoreTransactionConfig,\n\t): Promise<T> {\n\t\treturn this.session.transaction(transaction, config);\n\t}\n}\n\nexport type SingleStoreWithReplicas<Q> = Q & { $primary: Q };\n\nexport const withReplicas = <\n\tQ extends SingleStoreDriverDatabase,\n>(\n\tprimary: Q,\n\treplicas: [Q, ...Q[]],\n\tgetReplica: (replicas: Q[]) => Q = () => replicas[Math.floor(Math.random() * replicas.length)]!,\n): SingleStoreWithReplicas<Q> => {\n\tconst select: Q['select'] = (...args: []) => getReplica(replicas).select(...args);\n\tconst selectDistinct: Q['selectDistinct'] = (...args: []) => getReplica(replicas).selectDistinct(...args);\n\tconst $with: Q['with'] = (...args: []) => getReplica(replicas).with(...args);\n\n\tconst update: Q['update'] = (...args: [any]) => primary.update(...args);\n\tconst insert: Q['insert'] = (...args: [any]) => primary.insert(...args);\n\tconst $delete: Q['delete'] = (...args: [any]) => primary.delete(...args);\n\tconst execute: Q['execute'] = (...args: [any]) => primary.execute(...args);\n\tconst transaction: Q['transaction'] = (...args: [any, any]) => primary.transaction(...args);\n\n\treturn {\n\t\t...primary,\n\t\tupdate,\n\t\tinsert,\n\t\tdelete: $delete,\n\t\texecute,\n\t\ttransaction,\n\t\t$primary: primary,\n\t\tselect,\n\t\tselectDistinct,\n\t\twith: $with,\n\t\tget query() {\n\t\t\treturn getReplica(replicas).query;\n\t\t},\n\t};\n};\n"],"mappings":"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","names":[]}