uql-orm 0.9.3 → 0.9.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 (657) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +62 -683
  3. package/dist/browser/uql-browser.min.js +4791 -2940
  4. package/dist/browser/uql-browser.min.js.map +1 -1
  5. package/package.json +4 -4
  6. package/dist/browser/http/bus.d.ts +0 -4
  7. package/dist/browser/http/bus.d.ts.map +0 -1
  8. package/dist/browser/http/bus.js +0 -14
  9. package/dist/browser/http/bus.js.map +0 -1
  10. package/dist/browser/http/http.d.ts +0 -7
  11. package/dist/browser/http/http.d.ts.map +0 -1
  12. package/dist/browser/http/http.js +0 -45
  13. package/dist/browser/http/http.js.map +0 -1
  14. package/dist/browser/http/index.d.ts +0 -3
  15. package/dist/browser/http/index.d.ts.map +0 -1
  16. package/dist/browser/http/index.js +0 -3
  17. package/dist/browser/http/index.js.map +0 -1
  18. package/dist/browser/index.d.ts +0 -5
  19. package/dist/browser/index.d.ts.map +0 -1
  20. package/dist/browser/index.js +0 -5
  21. package/dist/browser/index.js.map +0 -1
  22. package/dist/browser/options.d.ts +0 -5
  23. package/dist/browser/options.d.ts.map +0 -1
  24. package/dist/browser/options.js +0 -14
  25. package/dist/browser/options.js.map +0 -1
  26. package/dist/browser/querier/httpQuerier.d.ts +0 -20
  27. package/dist/browser/querier/httpQuerier.d.ts.map +0 -1
  28. package/dist/browser/querier/httpQuerier.js +0 -68
  29. package/dist/browser/querier/httpQuerier.js.map +0 -1
  30. package/dist/browser/querier/index.d.ts +0 -3
  31. package/dist/browser/querier/index.d.ts.map +0 -1
  32. package/dist/browser/querier/index.js +0 -3
  33. package/dist/browser/querier/index.js.map +0 -1
  34. package/dist/browser/querier/querier.util.d.ts +0 -3
  35. package/dist/browser/querier/querier.util.d.ts.map +0 -1
  36. package/dist/browser/querier/querier.util.js +0 -17
  37. package/dist/browser/querier/querier.util.js.map +0 -1
  38. package/dist/browser/type/clientQuerier.d.ts +0 -24
  39. package/dist/browser/type/clientQuerier.d.ts.map +0 -1
  40. package/dist/browser/type/clientQuerier.js +0 -2
  41. package/dist/browser/type/clientQuerier.js.map +0 -1
  42. package/dist/browser/type/clientQuerierPool.d.ts +0 -5
  43. package/dist/browser/type/clientQuerierPool.d.ts.map +0 -1
  44. package/dist/browser/type/clientQuerierPool.js +0 -2
  45. package/dist/browser/type/clientQuerierPool.js.map +0 -1
  46. package/dist/browser/type/index.d.ts +0 -4
  47. package/dist/browser/type/index.d.ts.map +0 -1
  48. package/dist/browser/type/index.js +0 -4
  49. package/dist/browser/type/index.js.map +0 -1
  50. package/dist/browser/type/request.d.ts +0 -29
  51. package/dist/browser/type/request.d.ts.map +0 -1
  52. package/dist/browser/type/request.js +0 -2
  53. package/dist/browser/type/request.js.map +0 -1
  54. package/dist/bunSql/bunSql.util.d.ts +0 -30
  55. package/dist/bunSql/bunSql.util.d.ts.map +0 -1
  56. package/dist/bunSql/bunSql.util.js +0 -101
  57. package/dist/bunSql/bunSql.util.js.map +0 -1
  58. package/dist/bunSql/bunSqlPostgresDialect.d.ts +0 -12
  59. package/dist/bunSql/bunSqlPostgresDialect.d.ts.map +0 -1
  60. package/dist/bunSql/bunSqlPostgresDialect.js +0 -21
  61. package/dist/bunSql/bunSqlPostgresDialect.js.map +0 -1
  62. package/dist/bunSql/bunSqlQuerier.d.ts +0 -14
  63. package/dist/bunSql/bunSqlQuerier.d.ts.map +0 -1
  64. package/dist/bunSql/bunSqlQuerier.js +0 -37
  65. package/dist/bunSql/bunSqlQuerier.js.map +0 -1
  66. package/dist/bunSql/bunSqlQuerierPool.d.ts +0 -19
  67. package/dist/bunSql/bunSqlQuerierPool.d.ts.map +0 -1
  68. package/dist/bunSql/bunSqlQuerierPool.js +0 -58
  69. package/dist/bunSql/bunSqlQuerierPool.js.map +0 -1
  70. package/dist/bunSql/bunSqliteDialect.d.ts +0 -7
  71. package/dist/bunSql/bunSqliteDialect.d.ts.map +0 -1
  72. package/dist/bunSql/bunSqliteDialect.js +0 -7
  73. package/dist/bunSql/bunSqliteDialect.js.map +0 -1
  74. package/dist/bunSql/index.d.ts +0 -5
  75. package/dist/bunSql/index.d.ts.map +0 -1
  76. package/dist/bunSql/index.js +0 -5
  77. package/dist/bunSql/index.js.map +0 -1
  78. package/dist/cockroachdb/cockroachDialect.d.ts +0 -15
  79. package/dist/cockroachdb/cockroachDialect.d.ts.map +0 -1
  80. package/dist/cockroachdb/cockroachDialect.js +0 -14
  81. package/dist/cockroachdb/cockroachDialect.js.map +0 -1
  82. package/dist/cockroachdb/crdbQuerier.d.ts +0 -9
  83. package/dist/cockroachdb/crdbQuerier.d.ts.map +0 -1
  84. package/dist/cockroachdb/crdbQuerier.js +0 -7
  85. package/dist/cockroachdb/crdbQuerier.js.map +0 -1
  86. package/dist/cockroachdb/crdbQuerierPool.d.ts +0 -14
  87. package/dist/cockroachdb/crdbQuerierPool.d.ts.map +0 -1
  88. package/dist/cockroachdb/crdbQuerierPool.js +0 -18
  89. package/dist/cockroachdb/crdbQuerierPool.js.map +0 -1
  90. package/dist/cockroachdb/index.d.ts +0 -4
  91. package/dist/cockroachdb/index.d.ts.map +0 -1
  92. package/dist/cockroachdb/index.js +0 -4
  93. package/dist/cockroachdb/index.js.map +0 -1
  94. package/dist/d1/d1Querier.d.ts +0 -46
  95. package/dist/d1/d1Querier.d.ts.map +0 -1
  96. package/dist/d1/d1Querier.js +0 -30
  97. package/dist/d1/d1Querier.js.map +0 -1
  98. package/dist/d1/d1QuerierPool.d.ts +0 -11
  99. package/dist/d1/d1QuerierPool.d.ts.map +0 -1
  100. package/dist/d1/d1QuerierPool.js +0 -17
  101. package/dist/d1/d1QuerierPool.js.map +0 -1
  102. package/dist/d1/d1SqliteDialect.d.ts +0 -10
  103. package/dist/d1/d1SqliteDialect.d.ts.map +0 -1
  104. package/dist/d1/d1SqliteDialect.js +0 -10
  105. package/dist/d1/d1SqliteDialect.js.map +0 -1
  106. package/dist/d1/index.d.ts +0 -4
  107. package/dist/d1/index.d.ts.map +0 -1
  108. package/dist/d1/index.js +0 -4
  109. package/dist/d1/index.js.map +0 -1
  110. package/dist/dialect/abstractDialect.d.ts +0 -32
  111. package/dist/dialect/abstractDialect.d.ts.map +0 -1
  112. package/dist/dialect/abstractDialect.js +0 -39
  113. package/dist/dialect/abstractDialect.js.map +0 -1
  114. package/dist/dialect/abstractSqlDialect.d.ts +0 -233
  115. package/dist/dialect/abstractSqlDialect.d.ts.map +0 -1
  116. package/dist/dialect/abstractSqlDialect.js +0 -1332
  117. package/dist/dialect/abstractSqlDialect.js.map +0 -1
  118. package/dist/dialect/index.d.ts +0 -9
  119. package/dist/dialect/index.d.ts.map +0 -1
  120. package/dist/dialect/index.js +0 -9
  121. package/dist/dialect/index.js.map +0 -1
  122. package/dist/dialect/jsonArrayElemMatchUtils.d.ts +0 -10
  123. package/dist/dialect/jsonArrayElemMatchUtils.d.ts.map +0 -1
  124. package/dist/dialect/jsonArrayElemMatchUtils.js +0 -24
  125. package/dist/dialect/jsonArrayElemMatchUtils.js.map +0 -1
  126. package/dist/dialect/mysqlLikeSqlDialect.d.ts +0 -36
  127. package/dist/dialect/mysqlLikeSqlDialect.d.ts.map +0 -1
  128. package/dist/dialect/mysqlLikeSqlDialect.js +0 -84
  129. package/dist/dialect/mysqlLikeSqlDialect.js.map +0 -1
  130. package/dist/dialect/queryContext.d.ts +0 -49
  131. package/dist/dialect/queryContext.d.ts.map +0 -1
  132. package/dist/dialect/queryContext.js +0 -65
  133. package/dist/dialect/queryContext.js.map +0 -1
  134. package/dist/entity/decorator/entity.d.ts +0 -3
  135. package/dist/entity/decorator/entity.d.ts.map +0 -1
  136. package/dist/entity/decorator/entity.js +0 -7
  137. package/dist/entity/decorator/entity.js.map +0 -1
  138. package/dist/entity/decorator/field.d.ts +0 -3
  139. package/dist/entity/decorator/field.d.ts.map +0 -1
  140. package/dist/entity/decorator/field.js +0 -8
  141. package/dist/entity/decorator/field.js.map +0 -1
  142. package/dist/entity/decorator/hook.d.ts +0 -8
  143. package/dist/entity/decorator/hook.d.ts.map +0 -1
  144. package/dist/entity/decorator/hook.js +0 -15
  145. package/dist/entity/decorator/hook.js.map +0 -1
  146. package/dist/entity/decorator/id.d.ts +0 -3
  147. package/dist/entity/decorator/id.d.ts.map +0 -1
  148. package/dist/entity/decorator/id.js +0 -8
  149. package/dist/entity/decorator/id.js.map +0 -1
  150. package/dist/entity/decorator/index-decorator.d.ts +0 -37
  151. package/dist/entity/decorator/index-decorator.d.ts.map +0 -1
  152. package/dist/entity/decorator/index-decorator.js +0 -27
  153. package/dist/entity/decorator/index-decorator.js.map +0 -1
  154. package/dist/entity/decorator/index.d.ts +0 -8
  155. package/dist/entity/decorator/index.d.ts.map +0 -1
  156. package/dist/entity/decorator/index.js +0 -8
  157. package/dist/entity/decorator/index.js.map +0 -1
  158. package/dist/entity/decorator/relation.d.ts +0 -9
  159. package/dist/entity/decorator/relation.d.ts.map +0 -1
  160. package/dist/entity/decorator/relation.js +0 -20
  161. package/dist/entity/decorator/relation.js.map +0 -1
  162. package/dist/entity/index.d.ts +0 -2
  163. package/dist/entity/index.d.ts.map +0 -1
  164. package/dist/entity/index.js +0 -2
  165. package/dist/entity/index.js.map +0 -1
  166. package/dist/entity/metadata/definition.d.ts +0 -16
  167. package/dist/entity/metadata/definition.d.ts.map +0 -1
  168. package/dist/entity/metadata/definition.js +0 -309
  169. package/dist/entity/metadata/definition.js.map +0 -1
  170. package/dist/entity/test-helpers.d.ts +0 -4
  171. package/dist/entity/test-helpers.d.ts.map +0 -1
  172. package/dist/entity/test-helpers.js +0 -15
  173. package/dist/entity/test-helpers.js.map +0 -1
  174. package/dist/express/index.d.ts +0 -3
  175. package/dist/express/index.d.ts.map +0 -1
  176. package/dist/express/index.js +0 -3
  177. package/dist/express/index.js.map +0 -1
  178. package/dist/express/querierMiddleware.d.ts +0 -26
  179. package/dist/express/querierMiddleware.d.ts.map +0 -1
  180. package/dist/express/querierMiddleware.js +0 -143
  181. package/dist/express/querierMiddleware.js.map +0 -1
  182. package/dist/express/query.util.d.ts +0 -7
  183. package/dist/express/query.util.d.ts.map +0 -1
  184. package/dist/express/query.util.js +0 -27
  185. package/dist/express/query.util.js.map +0 -1
  186. package/dist/index.d.ts +0 -8
  187. package/dist/index.d.ts.map +0 -1
  188. package/dist/index.js +0 -8
  189. package/dist/index.js.map +0 -1
  190. package/dist/libsql/index.d.ts +0 -4
  191. package/dist/libsql/index.d.ts.map +0 -1
  192. package/dist/libsql/index.js +0 -4
  193. package/dist/libsql/index.js.map +0 -1
  194. package/dist/libsql/libsqlDialect.d.ts +0 -10
  195. package/dist/libsql/libsqlDialect.d.ts.map +0 -1
  196. package/dist/libsql/libsqlDialect.js +0 -10
  197. package/dist/libsql/libsqlDialect.js.map +0 -1
  198. package/dist/libsql/libsqlQuerier.d.ts +0 -24
  199. package/dist/libsql/libsqlQuerier.d.ts.map +0 -1
  200. package/dist/libsql/libsqlQuerier.js +0 -76
  201. package/dist/libsql/libsqlQuerier.js.map +0 -1
  202. package/dist/libsql/libsqlQuerierPool.d.ts +0 -20
  203. package/dist/libsql/libsqlQuerierPool.d.ts.map +0 -1
  204. package/dist/libsql/libsqlQuerierPool.js +0 -40
  205. package/dist/libsql/libsqlQuerierPool.js.map +0 -1
  206. package/dist/maria/index.d.ts +0 -4
  207. package/dist/maria/index.d.ts.map +0 -1
  208. package/dist/maria/index.js +0 -4
  209. package/dist/maria/index.js.map +0 -1
  210. package/dist/maria/mariaDialect.d.ts +0 -16
  211. package/dist/maria/mariaDialect.d.ts.map +0 -1
  212. package/dist/maria/mariaDialect.js +0 -56
  213. package/dist/maria/mariaDialect.js.map +0 -1
  214. package/dist/maria/mariadbQuerier.d.ts +0 -12
  215. package/dist/maria/mariadbQuerier.d.ts.map +0 -1
  216. package/dist/maria/mariadbQuerier.js +0 -31
  217. package/dist/maria/mariadbQuerier.js.map +0 -1
  218. package/dist/maria/mariadbQuerierPool.d.ts +0 -14
  219. package/dist/maria/mariadbQuerierPool.d.ts.map +0 -1
  220. package/dist/maria/mariadbQuerierPool.js +0 -18
  221. package/dist/maria/mariadbQuerierPool.js.map +0 -1
  222. package/dist/migrate/acquireQuerierForMigrations.d.ts +0 -9
  223. package/dist/migrate/acquireQuerierForMigrations.d.ts.map +0 -1
  224. package/dist/migrate/acquireQuerierForMigrations.js +0 -10
  225. package/dist/migrate/acquireQuerierForMigrations.js.map +0 -1
  226. package/dist/migrate/assertCliConfig.d.ts +0 -6
  227. package/dist/migrate/assertCliConfig.d.ts.map +0 -1
  228. package/dist/migrate/assertCliConfig.js +0 -31
  229. package/dist/migrate/assertCliConfig.js.map +0 -1
  230. package/dist/migrate/bin.d.ts +0 -3
  231. package/dist/migrate/bin.d.ts.map +0 -1
  232. package/dist/migrate/bin.js +0 -7
  233. package/dist/migrate/bin.js.map +0 -1
  234. package/dist/migrate/builder/columnBuilder.d.ts +0 -79
  235. package/dist/migrate/builder/columnBuilder.d.ts.map +0 -1
  236. package/dist/migrate/builder/columnBuilder.js +0 -159
  237. package/dist/migrate/builder/columnBuilder.js.map +0 -1
  238. package/dist/migrate/builder/expressions.d.ts +0 -87
  239. package/dist/migrate/builder/expressions.d.ts.map +0 -1
  240. package/dist/migrate/builder/expressions.js +0 -150
  241. package/dist/migrate/builder/expressions.js.map +0 -1
  242. package/dist/migrate/builder/index.d.ts +0 -6
  243. package/dist/migrate/builder/index.d.ts.map +0 -1
  244. package/dist/migrate/builder/index.js +0 -6
  245. package/dist/migrate/builder/index.js.map +0 -1
  246. package/dist/migrate/builder/migrationBuilder.d.ts +0 -110
  247. package/dist/migrate/builder/migrationBuilder.d.ts.map +0 -1
  248. package/dist/migrate/builder/migrationBuilder.js +0 -470
  249. package/dist/migrate/builder/migrationBuilder.js.map +0 -1
  250. package/dist/migrate/builder/splitSqlStatements.d.ts +0 -18
  251. package/dist/migrate/builder/splitSqlStatements.d.ts.map +0 -1
  252. package/dist/migrate/builder/splitSqlStatements.js +0 -44
  253. package/dist/migrate/builder/splitSqlStatements.js.map +0 -1
  254. package/dist/migrate/builder/tableBuilder.d.ts +0 -51
  255. package/dist/migrate/builder/tableBuilder.d.ts.map +0 -1
  256. package/dist/migrate/builder/tableBuilder.js +0 -291
  257. package/dist/migrate/builder/tableBuilder.js.map +0 -1
  258. package/dist/migrate/builder/types.d.ts +0 -466
  259. package/dist/migrate/builder/types.d.ts.map +0 -1
  260. package/dist/migrate/builder/types.js +0 -8
  261. package/dist/migrate/builder/types.js.map +0 -1
  262. package/dist/migrate/cli-config.d.ts +0 -3
  263. package/dist/migrate/cli-config.d.ts.map +0 -1
  264. package/dist/migrate/cli-config.js +0 -35
  265. package/dist/migrate/cli-config.js.map +0 -1
  266. package/dist/migrate/cli.d.ts +0 -20
  267. package/dist/migrate/cli.d.ts.map +0 -1
  268. package/dist/migrate/cli.js +0 -398
  269. package/dist/migrate/cli.js.map +0 -1
  270. package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -137
  271. package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +0 -1
  272. package/dist/migrate/codegen/entityCodeGenerator.js +0 -405
  273. package/dist/migrate/codegen/entityCodeGenerator.js.map +0 -1
  274. package/dist/migrate/codegen/entityMerger.d.ts +0 -115
  275. package/dist/migrate/codegen/entityMerger.d.ts.map +0 -1
  276. package/dist/migrate/codegen/entityMerger.js +0 -294
  277. package/dist/migrate/codegen/entityMerger.js.map +0 -1
  278. package/dist/migrate/codegen/index.d.ts +0 -11
  279. package/dist/migrate/codegen/index.d.ts.map +0 -1
  280. package/dist/migrate/codegen/index.js +0 -15
  281. package/dist/migrate/codegen/index.js.map +0 -1
  282. package/dist/migrate/codegen/migrationCodeGenerator.d.ts +0 -62
  283. package/dist/migrate/codegen/migrationCodeGenerator.d.ts.map +0 -1
  284. package/dist/migrate/codegen/migrationCodeGenerator.js +0 -356
  285. package/dist/migrate/codegen/migrationCodeGenerator.js.map +0 -1
  286. package/dist/migrate/codegen/migrationFile.d.ts +0 -29
  287. package/dist/migrate/codegen/migrationFile.d.ts.map +0 -1
  288. package/dist/migrate/codegen/migrationFile.js +0 -48
  289. package/dist/migrate/codegen/migrationFile.js.map +0 -1
  290. package/dist/migrate/codegen/smartRelationDetector.d.ts +0 -48
  291. package/dist/migrate/codegen/smartRelationDetector.d.ts.map +0 -1
  292. package/dist/migrate/codegen/smartRelationDetector.js +0 -135
  293. package/dist/migrate/codegen/smartRelationDetector.js.map +0 -1
  294. package/dist/migrate/drift/driftDetector.d.ts +0 -80
  295. package/dist/migrate/drift/driftDetector.d.ts.map +0 -1
  296. package/dist/migrate/drift/driftDetector.js +0 -247
  297. package/dist/migrate/drift/driftDetector.js.map +0 -1
  298. package/dist/migrate/drift/index.d.ts +0 -7
  299. package/dist/migrate/drift/index.d.ts.map +0 -1
  300. package/dist/migrate/drift/index.js +0 -7
  301. package/dist/migrate/drift/index.js.map +0 -1
  302. package/dist/migrate/generator/index.d.ts +0 -3
  303. package/dist/migrate/generator/index.d.ts.map +0 -1
  304. package/dist/migrate/generator/index.js +0 -3
  305. package/dist/migrate/generator/index.js.map +0 -1
  306. package/dist/migrate/generator/mongoSchemaGenerator.d.ts +0 -48
  307. package/dist/migrate/generator/mongoSchemaGenerator.d.ts.map +0 -1
  308. package/dist/migrate/generator/mongoSchemaGenerator.js +0 -188
  309. package/dist/migrate/generator/mongoSchemaGenerator.js.map +0 -1
  310. package/dist/migrate/index.d.ts +0 -16
  311. package/dist/migrate/index.d.ts.map +0 -1
  312. package/dist/migrate/index.js +0 -23
  313. package/dist/migrate/index.js.map +0 -1
  314. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +0 -77
  315. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +0 -1
  316. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +0 -156
  317. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +0 -1
  318. package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -26
  319. package/dist/migrate/introspection/baseSqlIntrospector.d.ts.map +0 -1
  320. package/dist/migrate/introspection/baseSqlIntrospector.js +0 -132
  321. package/dist/migrate/introspection/baseSqlIntrospector.js.map +0 -1
  322. package/dist/migrate/introspection/index.d.ts +0 -6
  323. package/dist/migrate/introspection/index.d.ts.map +0 -1
  324. package/dist/migrate/introspection/index.js +0 -6
  325. package/dist/migrate/introspection/index.js.map +0 -1
  326. package/dist/migrate/introspection/mongoIntrospector.d.ts +0 -15
  327. package/dist/migrate/introspection/mongoIntrospector.d.ts.map +0 -1
  328. package/dist/migrate/introspection/mongoIntrospector.js +0 -100
  329. package/dist/migrate/introspection/mongoIntrospector.js.map +0 -1
  330. package/dist/migrate/introspection/mysqlIntrospector.d.ts +0 -59
  331. package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +0 -1
  332. package/dist/migrate/introspection/mysqlIntrospector.js +0 -175
  333. package/dist/migrate/introspection/mysqlIntrospector.js.map +0 -1
  334. package/dist/migrate/introspection/postgresIntrospector.d.ts +0 -55
  335. package/dist/migrate/introspection/postgresIntrospector.d.ts.map +0 -1
  336. package/dist/migrate/introspection/postgresIntrospector.js +0 -226
  337. package/dist/migrate/introspection/postgresIntrospector.js.map +0 -1
  338. package/dist/migrate/introspection/sqliteIntrospector.d.ts +0 -60
  339. package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +0 -1
  340. package/dist/migrate/introspection/sqliteIntrospector.js +0 -188
  341. package/dist/migrate/introspection/sqliteIntrospector.js.map +0 -1
  342. package/dist/migrate/migrator.d.ts +0 -168
  343. package/dist/migrate/migrator.d.ts.map +0 -1
  344. package/dist/migrate/migrator.js +0 -614
  345. package/dist/migrate/migrator.js.map +0 -1
  346. package/dist/migrate/schemaGenerator.d.ts +0 -142
  347. package/dist/migrate/schemaGenerator.d.ts.map +0 -1
  348. package/dist/migrate/schemaGenerator.js +0 -693
  349. package/dist/migrate/schemaGenerator.js.map +0 -1
  350. package/dist/migrate/schemaGeneratorAsync.d.ts +0 -9
  351. package/dist/migrate/schemaGeneratorAsync.d.ts.map +0 -1
  352. package/dist/migrate/schemaGeneratorAsync.js +0 -13
  353. package/dist/migrate/schemaGeneratorAsync.js.map +0 -1
  354. package/dist/migrate/storage/databaseStorage.d.ts +0 -25
  355. package/dist/migrate/storage/databaseStorage.d.ts.map +0 -1
  356. package/dist/migrate/storage/databaseStorage.js +0 -78
  357. package/dist/migrate/storage/databaseStorage.js.map +0 -1
  358. package/dist/migrate/storage/index.d.ts +0 -3
  359. package/dist/migrate/storage/index.d.ts.map +0 -1
  360. package/dist/migrate/storage/index.js +0 -3
  361. package/dist/migrate/storage/index.js.map +0 -1
  362. package/dist/migrate/storage/jsonStorage.d.ts +0 -16
  363. package/dist/migrate/storage/jsonStorage.d.ts.map +0 -1
  364. package/dist/migrate/storage/jsonStorage.js +0 -43
  365. package/dist/migrate/storage/jsonStorage.js.map +0 -1
  366. package/dist/migrate/sync/index.d.ts +0 -7
  367. package/dist/migrate/sync/index.d.ts.map +0 -1
  368. package/dist/migrate/sync/index.js +0 -7
  369. package/dist/migrate/sync/index.js.map +0 -1
  370. package/dist/migrate/sync/schemaSync.d.ts +0 -132
  371. package/dist/migrate/sync/schemaSync.d.ts.map +0 -1
  372. package/dist/migrate/sync/schemaSync.js +0 -260
  373. package/dist/migrate/sync/schemaSync.js.map +0 -1
  374. package/dist/mongo/index.d.ts +0 -6
  375. package/dist/mongo/index.d.ts.map +0 -1
  376. package/dist/mongo/index.js +0 -6
  377. package/dist/mongo/index.js.map +0 -1
  378. package/dist/mongo/mongoDialect.d.ts +0 -83
  379. package/dist/mongo/mongoDialect.d.ts.map +0 -1
  380. package/dist/mongo/mongoDialect.js +0 -418
  381. package/dist/mongo/mongoDialect.js.map +0 -1
  382. package/dist/mongo/mongodbNativeDialect.d.ts +0 -10
  383. package/dist/mongo/mongodbNativeDialect.d.ts.map +0 -1
  384. package/dist/mongo/mongodbNativeDialect.js +0 -10
  385. package/dist/mongo/mongodbNativeDialect.js.map +0 -1
  386. package/dist/mongo/mongodbQuerier.d.ts +0 -46
  387. package/dist/mongo/mongodbQuerier.d.ts.map +0 -1
  388. package/dist/mongo/mongodbQuerier.js +0 -344
  389. package/dist/mongo/mongodbQuerier.js.map +0 -1
  390. package/dist/mongo/mongodbQuerierPool.d.ts +0 -12
  391. package/dist/mongo/mongodbQuerierPool.d.ts.map +0 -1
  392. package/dist/mongo/mongodbQuerierPool.js +0 -19
  393. package/dist/mongo/mongodbQuerierPool.js.map +0 -1
  394. package/dist/mysql/index.d.ts +0 -5
  395. package/dist/mysql/index.d.ts.map +0 -1
  396. package/dist/mysql/index.js +0 -5
  397. package/dist/mysql/index.js.map +0 -1
  398. package/dist/mysql/mysql2Dialect.d.ts +0 -10
  399. package/dist/mysql/mysql2Dialect.d.ts.map +0 -1
  400. package/dist/mysql/mysql2Dialect.js +0 -10
  401. package/dist/mysql/mysql2Dialect.js.map +0 -1
  402. package/dist/mysql/mysql2Querier.d.ts +0 -12
  403. package/dist/mysql/mysql2Querier.d.ts.map +0 -1
  404. package/dist/mysql/mysql2Querier.js +0 -34
  405. package/dist/mysql/mysql2Querier.js.map +0 -1
  406. package/dist/mysql/mysql2QuerierPool.d.ts +0 -12
  407. package/dist/mysql/mysql2QuerierPool.d.ts.map +0 -1
  408. package/dist/mysql/mysql2QuerierPool.js +0 -18
  409. package/dist/mysql/mysql2QuerierPool.js.map +0 -1
  410. package/dist/mysql/mysqlDialect.d.ts +0 -6
  411. package/dist/mysql/mysqlDialect.d.ts.map +0 -1
  412. package/dist/mysql/mysqlDialect.js +0 -6
  413. package/dist/mysql/mysqlDialect.js.map +0 -1
  414. package/dist/namingStrategy/defaultNamingStrategy.d.ts +0 -10
  415. package/dist/namingStrategy/defaultNamingStrategy.d.ts.map +0 -1
  416. package/dist/namingStrategy/defaultNamingStrategy.js +0 -15
  417. package/dist/namingStrategy/defaultNamingStrategy.js.map +0 -1
  418. package/dist/namingStrategy/index.d.ts +0 -3
  419. package/dist/namingStrategy/index.d.ts.map +0 -1
  420. package/dist/namingStrategy/index.js +0 -3
  421. package/dist/namingStrategy/index.js.map +0 -1
  422. package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +0 -9
  423. package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts.map +0 -1
  424. package/dist/namingStrategy/snakeCaseNamingStrategy.js +0 -14
  425. package/dist/namingStrategy/snakeCaseNamingStrategy.js.map +0 -1
  426. package/dist/neon/index.d.ts +0 -4
  427. package/dist/neon/index.d.ts.map +0 -1
  428. package/dist/neon/index.js +0 -4
  429. package/dist/neon/index.js.map +0 -1
  430. package/dist/neon/neonDialect.d.ts +0 -11
  431. package/dist/neon/neonDialect.d.ts.map +0 -1
  432. package/dist/neon/neonDialect.js +0 -11
  433. package/dist/neon/neonDialect.js.map +0 -1
  434. package/dist/neon/neonQuerier.d.ts +0 -6
  435. package/dist/neon/neonQuerier.d.ts.map +0 -1
  436. package/dist/neon/neonQuerier.js +0 -4
  437. package/dist/neon/neonQuerier.js.map +0 -1
  438. package/dist/neon/neonQuerierPool.d.ts +0 -11
  439. package/dist/neon/neonQuerierPool.d.ts.map +0 -1
  440. package/dist/neon/neonQuerierPool.js +0 -15
  441. package/dist/neon/neonQuerierPool.js.map +0 -1
  442. package/dist/options.d.ts +0 -5
  443. package/dist/options.d.ts.map +0 -1
  444. package/dist/options.js +0 -14
  445. package/dist/options.js.map +0 -1
  446. package/dist/postgres/abstractPgQuerier.d.ts +0 -24
  447. package/dist/postgres/abstractPgQuerier.d.ts.map +0 -1
  448. package/dist/postgres/abstractPgQuerier.js +0 -33
  449. package/dist/postgres/abstractPgQuerier.js.map +0 -1
  450. package/dist/postgres/abstractPgQuerierPool.d.ts +0 -15
  451. package/dist/postgres/abstractPgQuerierPool.d.ts.map +0 -1
  452. package/dist/postgres/abstractPgQuerierPool.js +0 -10
  453. package/dist/postgres/abstractPgQuerierPool.js.map +0 -1
  454. package/dist/postgres/index.d.ts +0 -6
  455. package/dist/postgres/index.d.ts.map +0 -1
  456. package/dist/postgres/index.js +0 -6
  457. package/dist/postgres/index.js.map +0 -1
  458. package/dist/postgres/pgDialect.d.ts +0 -13
  459. package/dist/postgres/pgDialect.d.ts.map +0 -1
  460. package/dist/postgres/pgDialect.js +0 -14
  461. package/dist/postgres/pgDialect.js.map +0 -1
  462. package/dist/postgres/pgQuerier.d.ts +0 -6
  463. package/dist/postgres/pgQuerier.d.ts.map +0 -1
  464. package/dist/postgres/pgQuerier.js +0 -4
  465. package/dist/postgres/pgQuerier.js.map +0 -1
  466. package/dist/postgres/pgQuerierPool.d.ts +0 -11
  467. package/dist/postgres/pgQuerierPool.d.ts.map +0 -1
  468. package/dist/postgres/pgQuerierPool.js +0 -15
  469. package/dist/postgres/pgQuerierPool.js.map +0 -1
  470. package/dist/postgres/postgresDialect.d.ts +0 -48
  471. package/dist/postgres/postgresDialect.d.ts.map +0 -1
  472. package/dist/postgres/postgresDialect.js +0 -222
  473. package/dist/postgres/postgresDialect.js.map +0 -1
  474. package/dist/postgres/postgresWireDriverCapabilities.d.ts +0 -15
  475. package/dist/postgres/postgresWireDriverCapabilities.d.ts.map +0 -1
  476. package/dist/postgres/postgresWireDriverCapabilities.js +0 -15
  477. package/dist/postgres/postgresWireDriverCapabilities.js.map +0 -1
  478. package/dist/querier/abstractPoolQuerier.d.ts +0 -14
  479. package/dist/querier/abstractPoolQuerier.d.ts.map +0 -1
  480. package/dist/querier/abstractPoolQuerier.js +0 -31
  481. package/dist/querier/abstractPoolQuerier.js.map +0 -1
  482. package/dist/querier/abstractQuerier.d.ts +0 -141
  483. package/dist/querier/abstractQuerier.d.ts.map +0 -1
  484. package/dist/querier/abstractQuerier.js +0 -431
  485. package/dist/querier/abstractQuerier.js.map +0 -1
  486. package/dist/querier/abstractQuerierPool.d.ts +0 -27
  487. package/dist/querier/abstractQuerierPool.d.ts.map +0 -1
  488. package/dist/querier/abstractQuerierPool.js +0 -31
  489. package/dist/querier/abstractQuerierPool.js.map +0 -1
  490. package/dist/querier/abstractSqlQuerier.d.ts +0 -53
  491. package/dist/querier/abstractSqlQuerier.d.ts.map +0 -1
  492. package/dist/querier/abstractSqlQuerier.js +0 -256
  493. package/dist/querier/abstractSqlQuerier.js.map +0 -1
  494. package/dist/querier/decorator/index.d.ts +0 -5
  495. package/dist/querier/decorator/index.d.ts.map +0 -1
  496. package/dist/querier/decorator/index.js +0 -5
  497. package/dist/querier/decorator/index.js.map +0 -1
  498. package/dist/querier/decorator/injectQuerier.d.ts +0 -4
  499. package/dist/querier/decorator/injectQuerier.d.ts.map +0 -1
  500. package/dist/querier/decorator/injectQuerier.js +0 -34
  501. package/dist/querier/decorator/injectQuerier.js.map +0 -1
  502. package/dist/querier/decorator/log.d.ts +0 -7
  503. package/dist/querier/decorator/log.d.ts.map +0 -1
  504. package/dist/querier/decorator/log.js +0 -27
  505. package/dist/querier/decorator/log.js.map +0 -1
  506. package/dist/querier/decorator/serialized.d.ts +0 -7
  507. package/dist/querier/decorator/serialized.d.ts.map +0 -1
  508. package/dist/querier/decorator/serialized.js +0 -14
  509. package/dist/querier/decorator/serialized.js.map +0 -1
  510. package/dist/querier/decorator/transactional.d.ts +0 -7
  511. package/dist/querier/decorator/transactional.d.ts.map +0 -1
  512. package/dist/querier/decorator/transactional.js +0 -49
  513. package/dist/querier/decorator/transactional.js.map +0 -1
  514. package/dist/querier/index.d.ts +0 -5
  515. package/dist/querier/index.d.ts.map +0 -1
  516. package/dist/querier/index.js +0 -5
  517. package/dist/querier/index.js.map +0 -1
  518. package/dist/schema/canonicalType.d.ts +0 -54
  519. package/dist/schema/canonicalType.d.ts.map +0 -1
  520. package/dist/schema/canonicalType.js +0 -571
  521. package/dist/schema/canonicalType.js.map +0 -1
  522. package/dist/schema/index.d.ts +0 -26
  523. package/dist/schema/index.d.ts.map +0 -1
  524. package/dist/schema/index.js +0 -27
  525. package/dist/schema/index.js.map +0 -1
  526. package/dist/schema/schemaAST.d.ts +0 -155
  527. package/dist/schema/schemaAST.d.ts.map +0 -1
  528. package/dist/schema/schemaAST.js +0 -496
  529. package/dist/schema/schemaAST.js.map +0 -1
  530. package/dist/schema/schemaASTBuilder.d.ts +0 -58
  531. package/dist/schema/schemaASTBuilder.d.ts.map +0 -1
  532. package/dist/schema/schemaASTBuilder.js +0 -228
  533. package/dist/schema/schemaASTBuilder.js.map +0 -1
  534. package/dist/schema/schemaASTDiffer.d.ts +0 -84
  535. package/dist/schema/schemaASTDiffer.d.ts.map +0 -1
  536. package/dist/schema/schemaASTDiffer.js +0 -431
  537. package/dist/schema/schemaASTDiffer.js.map +0 -1
  538. package/dist/schema/types.d.ts +0 -348
  539. package/dist/schema/types.d.ts.map +0 -1
  540. package/dist/schema/types.js +0 -11
  541. package/dist/schema/types.js.map +0 -1
  542. package/dist/sqlite/abstractSqliteQuerier.d.ts +0 -4
  543. package/dist/sqlite/abstractSqliteQuerier.d.ts.map +0 -1
  544. package/dist/sqlite/abstractSqliteQuerier.js +0 -4
  545. package/dist/sqlite/abstractSqliteQuerier.js.map +0 -1
  546. package/dist/sqlite/betterSqlite3Dialect.d.ts +0 -10
  547. package/dist/sqlite/betterSqlite3Dialect.d.ts.map +0 -1
  548. package/dist/sqlite/betterSqlite3Dialect.js +0 -10
  549. package/dist/sqlite/betterSqlite3Dialect.js.map +0 -1
  550. package/dist/sqlite/index.d.ts +0 -6
  551. package/dist/sqlite/index.d.ts.map +0 -1
  552. package/dist/sqlite/index.js +0 -6
  553. package/dist/sqlite/index.js.map +0 -1
  554. package/dist/sqlite/sqliteDialect.d.ts +0 -36
  555. package/dist/sqlite/sqliteDialect.d.ts.map +0 -1
  556. package/dist/sqlite/sqliteDialect.js +0 -155
  557. package/dist/sqlite/sqliteDialect.js.map +0 -1
  558. package/dist/sqlite/sqliteQuerier.d.ts +0 -14
  559. package/dist/sqlite/sqliteQuerier.d.ts.map +0 -1
  560. package/dist/sqlite/sqliteQuerier.js +0 -30
  561. package/dist/sqlite/sqliteQuerier.js.map +0 -1
  562. package/dist/sqlite/sqliteQuerierPool.d.ts +0 -14
  563. package/dist/sqlite/sqliteQuerierPool.d.ts.map +0 -1
  564. package/dist/sqlite/sqliteQuerierPool.js +0 -36
  565. package/dist/sqlite/sqliteQuerierPool.js.map +0 -1
  566. package/dist/type/config.d.ts +0 -43
  567. package/dist/type/config.d.ts.map +0 -1
  568. package/dist/type/config.js +0 -2
  569. package/dist/type/config.js.map +0 -1
  570. package/dist/type/entity.d.ts +0 -332
  571. package/dist/type/entity.d.ts.map +0 -1
  572. package/dist/type/entity.js +0 -5
  573. package/dist/type/entity.js.map +0 -1
  574. package/dist/type/index.d.ts +0 -12
  575. package/dist/type/index.d.ts.map +0 -1
  576. package/dist/type/index.js +0 -12
  577. package/dist/type/index.js.map +0 -1
  578. package/dist/type/logger.d.ts +0 -61
  579. package/dist/type/logger.d.ts.map +0 -1
  580. package/dist/type/logger.js +0 -2
  581. package/dist/type/logger.js.map +0 -1
  582. package/dist/type/migration.d.ts +0 -267
  583. package/dist/type/migration.d.ts.map +0 -1
  584. package/dist/type/migration.js +0 -2
  585. package/dist/type/migration.js.map +0 -1
  586. package/dist/type/migratorDialect.d.ts +0 -10
  587. package/dist/type/migratorDialect.d.ts.map +0 -1
  588. package/dist/type/migratorDialect.js +0 -16
  589. package/dist/type/migratorDialect.js.map +0 -1
  590. package/dist/type/namingStrategy.d.ts +0 -18
  591. package/dist/type/namingStrategy.d.ts.map +0 -1
  592. package/dist/type/namingStrategy.js +0 -2
  593. package/dist/type/namingStrategy.js.map +0 -1
  594. package/dist/type/querier.d.ts +0 -167
  595. package/dist/type/querier.d.ts.map +0 -1
  596. package/dist/type/querier.js +0 -11
  597. package/dist/type/querier.js.map +0 -1
  598. package/dist/type/querierPool.d.ts +0 -62
  599. package/dist/type/querierPool.d.ts.map +0 -1
  600. package/dist/type/querierPool.js +0 -2
  601. package/dist/type/querierPool.js.map +0 -1
  602. package/dist/type/query.d.ts +0 -703
  603. package/dist/type/query.d.ts.map +0 -1
  604. package/dist/type/query.js +0 -11
  605. package/dist/type/query.js.map +0 -1
  606. package/dist/type/universalQuerier.d.ts +0 -136
  607. package/dist/type/universalQuerier.d.ts.map +0 -1
  608. package/dist/type/universalQuerier.js +0 -2
  609. package/dist/type/universalQuerier.js.map +0 -1
  610. package/dist/type/utility.d.ts +0 -37
  611. package/dist/type/utility.d.ts.map +0 -1
  612. package/dist/type/utility.js +0 -2
  613. package/dist/type/utility.js.map +0 -1
  614. package/dist/util/ansiSqlLiteral.d.ts +0 -21
  615. package/dist/util/ansiSqlLiteral.d.ts.map +0 -1
  616. package/dist/util/ansiSqlLiteral.js +0 -101
  617. package/dist/util/ansiSqlLiteral.js.map +0 -1
  618. package/dist/util/dialect.util.d.ts +0 -31
  619. package/dist/util/dialect.util.d.ts.map +0 -1
  620. package/dist/util/dialect.util.js +0 -113
  621. package/dist/util/dialect.util.js.map +0 -1
  622. package/dist/util/field.util.d.ts +0 -14
  623. package/dist/util/field.util.d.ts.map +0 -1
  624. package/dist/util/field.util.js +0 -57
  625. package/dist/util/field.util.js.map +0 -1
  626. package/dist/util/hook.util.d.ts +0 -15
  627. package/dist/util/hook.util.d.ts.map +0 -1
  628. package/dist/util/hook.util.js +0 -20
  629. package/dist/util/hook.util.js.map +0 -1
  630. package/dist/util/index.d.ts +0 -10
  631. package/dist/util/index.d.ts.map +0 -1
  632. package/dist/util/index.js +0 -10
  633. package/dist/util/index.js.map +0 -1
  634. package/dist/util/logger.d.ts +0 -34
  635. package/dist/util/logger.d.ts.map +0 -1
  636. package/dist/util/logger.js +0 -129
  637. package/dist/util/logger.js.map +0 -1
  638. package/dist/util/object.util.d.ts +0 -10
  639. package/dist/util/object.util.d.ts.map +0 -1
  640. package/dist/util/object.util.js +0 -29
  641. package/dist/util/object.util.js.map +0 -1
  642. package/dist/util/raw.d.ts +0 -18
  643. package/dist/util/raw.d.ts.map +0 -1
  644. package/dist/util/raw.js +0 -20
  645. package/dist/util/raw.js.map +0 -1
  646. package/dist/util/relationQuery.util.d.ts +0 -25
  647. package/dist/util/relationQuery.util.d.ts.map +0 -1
  648. package/dist/util/relationQuery.util.js +0 -101
  649. package/dist/util/relationQuery.util.js.map +0 -1
  650. package/dist/util/sql.util.d.ts +0 -50
  651. package/dist/util/sql.util.d.ts.map +0 -1
  652. package/dist/util/sql.util.js +0 -141
  653. package/dist/util/sql.util.js.map +0 -1
  654. package/dist/util/string.util.d.ts +0 -29
  655. package/dist/util/string.util.d.ts.map +0 -1
  656. package/dist/util/string.util.js +0 -93
  657. package/dist/util/string.util.js.map +0 -1
package/README.md CHANGED
@@ -1,749 +1,128 @@
1
1
  <!-- ![code](/assets/code.webp 'code') -->
2
2
 
3
- <a href="https://uql-orm.dev"><img src="assets/logo.svg" alt="uql" width="80" /></a>
3
+ <picture>
4
+ <source srcset="assets/logo-dark.svg" media="(prefers-color-scheme: dark)">
5
+ <a href="https://uql-orm.dev"><img src="assets/logo.svg" alt="uql" width="80" /></a>
6
+ </picture>
4
7
 
5
- [![tests](https://github.com/rogerpadilla/uql/actions/workflows/tests.yml/badge.svg)](https://github.com/rogerpadilla/uql) [![Coverage Status](https://coveralls.io/repos/github/rogerpadilla/uql/badge.svg?branch=main)](https://coveralls.io/github/rogerpadilla/uql?branch=main) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/uql-orm.svg)](https://www.npmjs.com/package/uql-orm)
8
+ [![tests](https://github.com/rogerpadilla/uql/actions/workflows/tests.yml/badge.svg)](https://github.com/rogerpadilla/uql/actions/workflows/tests.yml) [![Coverage Status](https://coveralls.io/repos/github/rogerpadilla/uql/badge.svg?branch=main)](https://coveralls.io/github/rogerpadilla/uql?branch=main) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/uql-orm.svg)](https://www.npmjs.com/package/uql-orm)
6
9
 
7
- **[UQL](https://uql-orm.dev)** is the best ORM for TypeScript and modern JavaScript designed to be fast, safe, and easy to integrate into any application especially AI and data‑heavy workloads. Built with a unified API across SQL and MongoDB.
10
+ **[UQL](https://uql-orm.dev)** is the JSON-native TypeScript ORM: serializable queries, no codegen, and one API across PostgreSQL, MySQL, SQLite, MariaDB, and MongoDB. Define entities once, query everywhere.
11
+
12
+ <!-- DEMO: Record an animated GIF showing IDE autocompletion for $select/$populate/$where and embed here. Example: ![demo](/assets/demo.gif) -->
8
13
 
9
14
  ```ts
10
- const results = await querier.findMany(User, {
11
- $select: { name: true },
12
- $populate: { profile: { $select: { picture: true } } },
13
- $where: { name: { $istartsWith: 'a' }, posts: { tags: { name: 'typescript' } } },
14
- $sort: { createdAt: 'desc' },
15
+ await querier.findMany(User, {
16
+ $select: { id: true, name: true },
17
+ $where: { email: { $endsWith: '@uql-orm.dev' } },
15
18
  $limit: 10,
16
19
  });
17
20
  ```
18
21
 
19
- ## Quick Start
20
-
21
- ```sh
22
- npm install uql-orm pg
23
- ```
24
- _(Example using PostgreSQL; see [Install](#1-install) for other databases)_
25
-
26
- ```ts
27
- import { PgQuerierPool } from 'uql-orm/postgres';
28
-
29
- const pool = new PgQuerierPool({ host: 'localhost', database: 'app' });
30
- const users = await pool.withQuerier((querier) => querier.findMany(User, { $limit: 10 }));
31
- ```
32
-
33
- For production setup and migrations, jump to:
34
- - [Install](#1-install)
35
- - [Define your Entities](#2-define-your-entities)
36
- - [Migrations & Synchronization](#5-migrations--synchronization)
22
+ Full docs: **[uql-orm.dev](https://uql-orm.dev)**
37
23
 
38
- > **Note:** For explicit lifecycle control, use manual `getQuerier()` + `release()` (shown in [Core Query Pattern](#core-query-pattern)).
24
+ ---
39
25
 
40
- ## Guide Map
26
+ ## Why UQL?
41
27
 
42
- Core path:
43
- - [1. Install](#1-install)
44
- - [2. Define your Entities](#2-define-your-entities)
45
- - [3. Set up a pool](#3-set-up-a-pool)
46
- - [4. Manipulate the Data](#4-manipulate-the-data)
47
- - [5. Migrations & Synchronization](#5-migrations--synchronization)
48
-
49
- Advanced and operations:
50
- - [Semantic Search](#modern-indexing-semantic-search)
51
- - [JSON Operators & Relation Filtering](#json-operators--relation-filtering)
52
- - [Thread-Safe Transactions](#thread-safe-transactions)
53
- - [6. Logging & Monitoring](#6-logging--monitoring)
54
- - [Deep Dive: Tests & Technical Resources](#deep-dive-tests--technical-resources)
28
+ - **Queries are data, not method chains.** A UQL query is a plain JSON object. Build them dynamically, store them, or send them from client to server without a DSL.
29
+ - **No codegen, no build step.** Entities are TypeScript classes, so your code *is* the schema. No `.prisma` files or generated clients to keep in sync.
30
+ - **One API everywhere.** The same syntax runs on PostgreSQL, MySQL, MariaDB, SQLite, LibSQL, Neon, Cloudflare D1, MongoDB, and Bun's native SQL.
31
+ - **Fast by design.** Fastest in [all 8 categories](https://uql-orm.dev/benchmark) of our [open benchmark](https://github.com/rogerpadilla/ts-orm-benchmark): on average ~2.1× faster than the runner-up, reaching 3.5M ops/s on SELECTs and DELETEs.
55
32
 
56
33
  ## Features
57
34
 
58
- | Feature | Why it matters |
35
+ | Feature | Docs |
59
36
  | :--- | :--- |
60
- | **[Intelligent Querying](https://uql-orm.dev/querying/relations)** | Deep auto-completion for operators and relations at any depth—no more guessing property names. |
61
- | **Serializable JSON** | Query objects are valid JSON, which makes them straightforward to transport over HTTP/gRPC/WebSockets. |
62
- | **Unified Dialects** | Write once, run anywhere. Seamlessly switch between PostgreSQL, MySQL, MariaDB, SQLite, and MongoDB. |
63
- | **[Naming Strategies](https://uql-orm.dev/naming-strategy)** | No more `camelCase` vs `snake_case` headaches. Map your code to your database automatically. |
64
- | **Smart SQL Engine** | Zero-allocation SQL generation with top-ranked results in our [open benchmark](https://github.com/rogerpadilla/ts-orm-benchmark). |
65
- | **Thread-Safe by Design** | Protect your data integrity with centralized task queues and the `@Serialized()` decorator. |
66
- | **[Declarative Transactions](https://uql-orm.dev/querying/transactions)** | Clean `@Transactional()` decorators that work beautifully with modern DI frameworks like NestJS. |
67
- | **[Lifecycle Hooks](https://uql-orm.dev/entities/lifecycle-hooks)** | Automate validation, timestamps, and computed logic with intuitive class-based decorators. |
68
- | **[Aggregate Queries](https://uql-orm.dev/querying/aggregate)** | Real-time analytics with `GROUP BY`, `HAVING`, and native math operators across all dialects. |
69
- | **[Semantic Search](https://uql-orm.dev/querying/semantic-search)** | Native vector similarity search. Rank results by meaning using standard ORM operators. |
70
- | **[Cursor Streaming](https://uql-orm.dev/querying/streaming)** | Process millions of rows with a stable memory footprint using native driver-level cursors. |
71
- | **[Modern & Versatile](https://uql-orm.dev/entities/virtual-fields)** | Pure ESM, high-res timing, built-in soft-delete, and first-class JSON/JSONB support. |
72
- | **[Database Migrations](https://www.uql-orm.dev/migrations)** | Entity-First synchronization. DDL is auto-generated by diffing your code against the live DB. |
73
- | **[Logging & Monitoring](https://www.uql-orm.dev/logging)** | High-visibility debugging with slow-query detection and high-contrast terminal output. |
74
- | **[Fullstack Bridge](https://www.uql-orm.dev/comparison#network-boundaries--apis)** | Speak to your database from the browser securely. First-party `HttpQuerier` removes API boilerplate. |
75
-
76
- ## 1. Install
77
-
78
- Install the core package and the driver for your database:
37
+ | Unified API across SQL + MongoDB | [Install](https://uql-orm.dev/getting-started) |
38
+ | Type-safe queries with autocomplete | [Querying](https://uql-orm.dev/querying/querier) |
39
+ | Entity-first migrations & autoSync | [Migrations](https://uql-orm.dev/migrations) |
40
+ | Soft-delete, lifecycle hooks, relations | [Entities](https://uql-orm.dev/entities/basic) |
41
+ | Aggregate queries, grouping, HAVING | [Aggregate](https://uql-orm.dev/querying/aggregate) |
42
+ | Semantic search & vector similarity | [Semantic Search](https://uql-orm.dev/ai-semantic-search) |
43
+ | Streaming, transactions, raw SQL | [Querying](https://uql-orm.dev/querying/querier) |
44
+ | NestJS integration & HttpQuerier | [Fullstack](https://uql-orm.dev/comparison) |
79
45
 
80
- ```sh
81
- # Core
82
- npm install uql-orm # or bun add / pnpm add
83
- ```
84
-
85
- ### Supported Drivers (pick according to your database)
46
+ ## Install
86
47
 
87
- | Database | Command |
88
- | :--- | :--- |
89
- | **PostgreSQL** (incl. Neon, Cockroach, Yugabyte) | `npm install pg` |
90
- | **MySQL** (incl. TiDB, Aurora) | `npm install mysql2` |
91
- | **MariaDB** | `npm install mariadb` |
92
- | **SQLite** | `npm install better-sqlite3` |
93
- | **LibSQL** (incl. Turso) | `npm install @libsql/client` |
94
- | **MongoDB** | `npm install mongodb` |
95
- | **Cloudflare D1** | _Native (no driver needed)_ |
96
- | **Bun SQL Native** (Incl. Postgres, MySQL, SQLite) | _Native (via `bun:sql`)_ |
97
-
98
- ### TypeScript Configuration
99
-
100
- If you use the **decorator-based approach**, make sure your `tsconfig.json` is configured to support decorators and metadata:
101
-
102
-
103
- ```json
104
- {
105
- "compilerOptions": {
106
- "experimentalDecorators": true,
107
- "emitDecoratorMetadata": true
108
- }
109
- }
48
+ ```sh
49
+ npm install uql-orm pg # or mysql2, mariadb, better-sqlite3, mongodb, @libsql/client
110
50
  ```
111
51
 
112
- > **Note:** UQL is Modern Pure ESM ensure your project's `module` supports ESM imports (e.g., `NodeNext`, `ESNext`, `Bundler`).
52
+ Supports PostgreSQL, MySQL, MariaDB, SQLite, CockroachDB, LibSQL/Turso, Neon, MongoDB, Cloudflare D1, and Bun SQL.
113
53
 
114
- ## 2. Define your Entities
54
+ ## Define Entities
115
55
 
116
- [Declare](https://uql-orm.dev/entities/basic) your classes with decorators, or use the [imperative](https://uql-orm.dev/entities/imperative) approach for decorator-free registration. UQL's engine uses this metadata for both type-safe querying and precise DDL generation. This includes the new **`defineEntity`** API which works without requiring `experimentalDecorators` in your `tsconfig.json`.
117
-
118
- ### Core Decorators
119
-
120
- | Decorator | Purpose |
121
- | :--- | :--- |
122
- | `@Entity()` | Marks a class as a database table/collection. |
123
- | `@Id()` | Defines the Primary Key with support for `onInsert` generators. |
124
- | `@Field()` | Standard column. Use `{ references: ... }` for Foreign Keys. |
125
- | `@Index()` | Defines a composite or custom index on one or more columns. |
126
- | `@OneToOne` | Defines a one-to-one relationship. |
127
- | `@OneToMany` | Defines a one-to-many relationship. |
128
- | `@ManyToOne` | Defines a many-to-one relationship. |
129
- | `@ManyToMany` | Defines a many-to-many relationship. |
130
- | `@BeforeInsert` | Lifecycle hooks fired around database operations. |
131
- | `@AfterLoad` | Lifecycle hook fired after loading entities. |
132
-
133
- ### Type Abstraction: Logical vs. Physical
134
-
135
- UQL separates the **intent** of your data from its **storage**. Both properties are **optional**; if omitted, UQL performs a *best-effort inference* using the TypeScript types from your class.
136
-
137
- | Property | Purpose | Values |
138
- | :--- | :--- | :--- |
139
- | **`type`** | **Logical Type** (Abstraction). Used for runtime behavior and automatic SQL mapping. | `String`, `Number`, `Boolean`, `Date`, `BigInt`, or semantic strings: `'uuid'`, `'json'`, `'vector'`, `'halfvec'`, `'sparsevec'`. |
140
- | **`columnType`** | **Physical Type** (Implementation). **Highest Priority**. Bypasses UQL's inference for exact SQL control. | Raw SQL types: `'varchar(100)'`, `'decimal(10,2)'`, `'smallint'`, etc. |
141
-
142
- ```ts
143
- // Automatic inference from TypeScript types
144
- @Field() name?: string; // → TEXT (Postgres), VARCHAR(255) (MySQL)
145
- @Field() age?: number; // → INTEGER
146
- @Field() isActive?: boolean; // → BOOLEAN
147
- @Field() createdAt?: Date; // → TIMESTAMP
148
-
149
- // Semantic types - portable across all databases
150
- @Field({ type: 'uuid' }) // → UUID (Postgres), CHAR(36) (MySQL), TEXT (SQLite)
151
- externalId?: string;
152
-
153
- @Field({ type: 'json' }) // → JSONB (Postgres), JSON (MySQL), TEXT (SQLite)
154
- metadata?: Json<{ theme?: string }>;
155
-
156
- // Logical types with constraints - portable with control
157
- @Field({ type: 'varchar', length: 500 })
158
- bio?: string;
159
-
160
- @Field({ type: 'decimal', precision: 10, scale: 2 })
161
- price?: number;
162
-
163
- // Exact SQL type - when you need dialect-specific control
164
- @Field({ columnType: 'smallint' })
165
- statusCode?: number;
166
- ```
167
-
168
- > **Note:** Use the `Relation<T>` utility type for relationship properties. It prevents TypeScript circular dependency errors while maintaining full type-safety throughout your app.
56
+ [Declare](https://uql-orm.dev/entities/basic) your classes with decorators. UQL uses this metadata for type-safe querying and DDL generation.
169
57
 
170
58
  ```ts
171
59
  import { v7 as uuidv7 } from 'uuid';
172
- import { Entity, Id, Field, OneToOne, OneToMany, ManyToOne, ManyToMany, type Relation, type Json } from 'uql-orm';
60
+ import { Entity, Id, Field, OneToOne, OneToMany, type Relation } from 'uql-orm';
173
61
 
174
62
  @Entity()
175
63
  export class User {
176
64
  @Id({ type: 'uuid', onInsert: () => uuidv7() })
177
65
  id?: string;
178
66
 
179
- @Field({
180
- index: true,
181
- })
182
- name?: string;
183
-
184
- @Field({
185
- unique: true,
186
- comment: 'User login email',
187
- })
67
+ @Field({ index: true, unique: true })
188
68
  email?: string;
189
69
 
190
- @OneToOne({
191
- entity: () => Profile,
192
- mappedBy: (profile) => profile.user,
193
- cascade: true,
194
- })
70
+ @OneToOne({ entity: () => Profile, mappedBy: (p) => p.user, cascade: true })
195
71
  profile?: Relation<Profile>;
196
72
 
197
- @OneToMany({
198
- entity: () => Post,
199
- mappedBy: (post) => post.author,
200
- })
73
+ @OneToMany({ entity: () => Post, mappedBy: (p) => p.author })
201
74
  posts?: Relation<Post>[];
202
75
  }
203
-
204
- @Entity()
205
- export class Profile {
206
- @Id({ type: 'uuid', onInsert: () => uuidv7() })
207
- id?: string;
208
-
209
- @Field()
210
- bio?: string;
211
-
212
- @Field({ references: () => User, foreignKey: 'fk_profile_user' })
213
- userId?: string;
214
-
215
- @OneToOne({ entity: () => User })
216
- user?: User;
217
- }
218
-
219
- @Entity()
220
- export class Post {
221
- @Id()
222
- id?: number;
223
-
224
- @Field()
225
- title?: string;
226
-
227
- @Field({ references: () => User })
228
- authorId?: string;
229
-
230
- @ManyToOne({ entity: () => User })
231
- author?: User;
232
-
233
- @ManyToMany({
234
- entity: () => Tag,
235
- through: () => PostTag,
236
- })
237
- tags?: Tag[];
238
- }
239
-
240
- @Entity()
241
- export class Tag {
242
- @Id({ type: 'uuid', onInsert: () => uuidv7() })
243
- id?: string;
244
-
245
- @Field()
246
- name?: string;
247
- }
248
-
249
- @Entity()
250
- export class PostTag {
251
- @Id({ type: 'uuid', onInsert: () => uuidv7() })
252
- id?: string;
253
-
254
- @Field({ references: () => Post })
255
- postId?: number;
256
-
257
- @Field({ references: () => Tag })
258
- tagId?: string;
259
- }
260
-
261
- ### Alternative: Imperative (Decorator-free) Definition
262
-
263
- If you prefer a functional approach or are in an environment where decorators are disabled (e.g., some edge runtimes or specific build pipelines), you can register entities imperatively using `defineEntity`. **Crucially, this approach works without requiring `experimentalDecorators` or `emitDecoratorMetadata` in your `tsconfig.json`.**
264
-
265
- This API supports bulk configuration of `fields`, `relations`, `indexes`, and `hooks` directly within the options object. UQL also exports helper functions like `defineField`, `defineId`, and `defineRelation` to assist with type-safe imperative setup.
266
-
267
- ```ts
268
- import { defineEntity } from 'uql-orm';
269
-
270
- class User {}
271
-
272
- defineEntity(User, {
273
- name: 'users',
274
- fields: {
275
- id: { type: 'uuid', isId: true },
276
- name: { type: String },
277
- email: { type: String, unique: true },
278
- },
279
-
280
- indexes: [
281
- { columns: ['email'], unique: true },
282
- ],
283
- // You can also define hooks and relations here
284
- });
285
- ```
286
- ```
287
-
288
-
289
- ## 3. Set up a pool
290
-
291
- A pool manages connections (queriers). Initialize it once at application bootstrap (e.g., in `server.ts`).
292
-
293
- ```ts
294
- import { SnakeCaseNamingStrategy, type Config } from 'uql-orm';
295
- import { PgQuerierPool } from 'uql-orm/postgres'; // or mysql2, sqlite, bunSql, etc.
296
- import { User, Profile, Post } from './entities';
297
-
298
- export const pool = new PgQuerierPool(
299
- { host: 'localhost', database: 'uql_app', max: 10 },
300
- {
301
- logger: ['error', 'warn', 'migration'],
302
- namingStrategy: new SnakeCaseNamingStrategy(),
303
- slowQuery: { threshold: 1000 },
304
- }
305
- );
306
-
307
- export default {
308
- pool,
309
- entities: [User, Profile, Post],
310
- migrationsPath: './migrations',
311
- } satisfies Config;
312
- ```
313
-
314
- > **Notes:**
315
- > - Reuse one pool for both app queries and migrations to keep behavior (for example naming strategy) consistent.
316
- > - **LibSQL embedded replica** (`file:` + `syncUrl`): `LibsqlQuerierPool` runs **migrations and the `uql_migrations` table** against **`syncUrl`**, while **`getQuerier`** stays on the local file. **`getDiffs` / introspection** (e.g. `generate:entities`) still use the normal pool connection—often the local replica—so compare with your remote if needed.
317
- > - If your architecture spans backend + browser, `HttpQuerier` reduces custom API mapping and keeps query semantics aligned.
318
- > - **Upgrading:** use `pool.dialect` (not `pool.dialectInstance`), read `pool.dialect.dialectName`, and remove any top-level `dialect` from migrate config (see `CHANGELOG.md`).
319
-
320
- ### Driver → pool → dialect class
321
-
322
- Migrations and the CLI read **`pool.dialect.dialectName`** only (there is no separate top-level `dialect` in config). Pick the pool (and thus the dialect class) for your driver.
323
-
324
- | Import path | Pool class | Dialect class (on the pool) | Notes |
325
- | :--- | :--- | :--- | :--- |
326
- | `uql-orm/postgres` | `PgQuerierPool` | `PgDialect` | Node `pg`; base Postgres capabilities (native arrays, `$n::jsonb`). |
327
- | `uql-orm/postgres` | — | `PostgresDialect` | Base Postgres AST; subclass for other Postgres wire drivers. |
328
- | `uql-orm/neon` | `NeonQuerierPool` | `NeonDialect` | `@neondatabase/serverless`; extends `PostgresDialect` with Neon-oriented defaults. |
329
- | `uql-orm/cockroachdb` | `CrdbQuerierPool` | `CockroachDialect` | `dialectName` is `cockroachdb`; extends `PostgresDialect`. |
330
- | `uql-orm/mysql` | `Mysql2QuerierPool` | `MySql2Dialect` | `mysql2` driver. |
331
- | `uql-orm/maria` | `MariadbQuerierPool` | `MariaDialect` | `mariadb` driver. |
332
- | `uql-orm/sqlite` | `Sqlite3QuerierPool` | `BetterSqlite3Dialect` | `better-sqlite3` (or Bun SQLite in that pool). |
333
- | `uql-orm/libsql` | `LibsqlQuerierPool` | `LibsqlDialect` | `@libsql/client`. |
334
- | `uql-orm/d1` | `D1QuerierPool` | `D1SqliteDialect` | Cloudflare D1. |
335
- | `uql-orm/mongo` | `MongodbQuerierPool` | `MongodbNativeDialect` | Official `mongodb` driver. |
336
- | `uql-orm/bunSql` | `BunSqlQuerierPool` | _inferred_ | Dialect class chosen from `SQL.Options` (Postgres / MySQL / MariaDB / SQLite / Cockroach). |
337
-
338
- For **wire-level** differences on PostgreSQL (e.g. Bun SQL vs `pg`), `BunSqlPostgresDialect` merges `POSTGRES_WIRE_DRIVER_CAPABILITIES` from `uql-orm/postgres/wireCapabilities` (array literals + JSON text cast); `PgDialect` does not.
339
-
340
- ## 4. Manipulate the Data
341
-
342
- UQL provides a straightforward API to interact with your data. **Always ensure queriers are released back to the pool.**
343
-
344
- ### Core Query Pattern
345
-
346
- ```ts
347
- const querier = await pool.getQuerier();
348
- try {
349
- const results = await querier.findMany(User, {
350
- $select: { name: true },
351
- $populate: { profile: { $select: { bio: true }, $required: true } }, // INNER JOIN
352
- $where: {
353
- status: 'active',
354
- name: { $istartsWith: 'a' },
355
- },
356
- $limit: 10,
357
- });
358
- } finally {
359
- await querier.release(); // Always release back to the pool
360
- }
361
- ```
362
-
363
- **Generated SQL (PostgreSQL):**
364
-
365
- ```sql
366
- SELECT "User"."name", "profile"."id" AS "profile_id", "profile"."bio" AS "profile_bio"
367
- FROM "User"
368
- INNER JOIN "Profile" AS "profile" ON "profile"."userId" = "User"."id"
369
- WHERE "User"."status" = 'active' AND "User"."name" ILIKE 'a%'
370
- LIMIT 10 OFFSET 0
371
- ```
372
-
373
- ### Projection & Relation Loading
374
-
375
- Use these query keys with clear separation of concerns:
376
-
377
- - `$select`: scalar field whitelist (projection)
378
- - `$exclude`: scalar field subtraction from default eager set
379
- - `$populate`: relation loading (including nested relation query options)
380
-
381
- `$select` and `$exclude` are mutually exclusive when `$select` includes positive scalar keys.
382
-
383
- ```ts
384
- const rows = await querier.findMany(User, {
385
- $exclude: { password: true },
386
- $populate: { profile: { $select: { picture: true } } },
387
- });
388
- ```
389
-
390
- > **Migration note:** selecting relations inside `$select` is still supported for backward compatibility, but deprecated. Move relations to `$populate`.
391
-
392
- ### Streaming (`findManyStream`) and relations
393
-
394
- `findManyStream` is optimized for **scalar** reads and a stable memory footprint. Relation loading differs by backend:
395
-
396
- - **SQL:** Joinable relations (e.g. many-to-one, one-to-one) are still included in the streamed `SELECT` / joins. **To-many** collections are not filled on the stream path (that uses extra queries in `findMany`); requesting them in `$select` / `$populate` throws a `TypeError` with a short explanation.
397
- - **MongoDB:** Streams use a plain `find` cursor, so **any** relation keys in `$select` or `$populate` throw a `TypeError`. Use `findMany` for relation loading (aggregation + fill).
398
-
399
- See [Cursor Streaming](https://uql-orm.dev/querying/streaming) on the docs site for details.
400
-
401
- ### Advanced Query Patterns
402
-
403
- ### Modern Indexing: Semantic Search
404
-
405
- AI-driven applications require ranking results by meaning. UQL treats vector similarity as a first-class citizen, allowing you to perform semantic search without raw SQL or proprietary extensions.
406
-
407
- ```ts
408
- const results = await querier.findMany(Item, {
409
- $select: { id: true, title: true },
410
- $sort: { $vector: { embedding: queryVector } },
411
- $limit: 10,
412
- });
413
- ```
414
-
415
- ### Advanced: Virtual Fields & Raw SQL
416
-
417
- Define complex logic directly in your entities using `raw` functions. These are resolved during SQL generation for peak efficiency.
418
-
419
- ```ts
420
- @Entity()
421
- export class Item {
422
- @Field({
423
- virtual: raw(({ ctx, dialect, escapedPrefix }) => {
424
- ctx.append('(');
425
- dialect.count(ctx, ItemTag, {
426
- $where: { itemId: raw(({ ctx }) => ctx.append(`${escapedPrefix}.id`)) }
427
- }, { autoPrefix: true });
428
- ctx.append(')');
429
- })
430
- })
431
- tagsCount?: number;
432
- }
433
76
  ```
434
77
 
435
- ### JSON Operators & Relation Filtering
436
-
437
- Query nested JSON fields using **type-safe dot-notation** with full operator support. Wrap fields with `Json<T>` to get IDE autocompletion for valid paths. UQL generates native SQL per dialect.
438
-
439
- ```ts
440
- // Filter by nested JSONB field paths
441
- const items = await querier.findMany(Company, {
442
- $where: {
443
- 'settings.isArchived': { $ne: true },
444
- 'settings.priority': { $gte: 5 },
445
- },
446
- });
447
- ```
448
-
449
- **PostgreSQL:** `WHERE ("settings"->>'isArchived') IS DISTINCT FROM $1 AND (("settings"->>'priority'))::numeric >= $2`
450
- **MySQL:** `WHERE (\`settings\`->>'isArchived') <> ? AND CAST((\`settings\`->>'priority') AS DECIMAL) >= ?`
451
- **MariaDB:** `WHERE JSON_VALUE(\`settings\`, '$.isArchived') <> ? AND CAST(JSON_VALUE(\`settings\`, '$.priority') AS DECIMAL) >= ?`
452
- **SQLite:** `WHERE json_extract("settings", '$.isArchived') IS NOT ? AND CAST(json_extract("settings", '$.priority') AS REAL) >= ?`
453
-
454
- Atomic JSON updates support `$merge`, `$unset`, and `$push`:
455
-
456
- ```ts
457
- await querier.updateOneById(Company, id, {
458
- settings: { $merge: { theme: 'dark' }, $push: { tags: 'orm' }, $unset: ['deprecated'] },
459
- });
460
- ```
461
-
462
- > **Modern DB Baselines used by docs/examples:** PostgreSQL 16+, MySQL 8.4+ (LTS), MariaDB 12.2+, SQLite 3.45+.
463
- > Full generated SQL examples: [JSON / JSONB docs](https://uql-orm.dev/querying/json).
464
-
465
- Filter parent entities by their **ManyToMany** or **OneToMany** relations using automatic EXISTS subqueries:
466
-
467
- ```ts
468
- // Find posts that have a tag named 'typescript'
469
- const posts = await querier.findMany(Post, {
470
- $where: { tags: { name: 'typescript' } },
471
- });
472
- ```
473
-
474
- **PostgreSQL:** `WHERE EXISTS (SELECT 1 FROM "PostTag" WHERE "PostTag"."postId" = "Post"."id" AND "PostTag"."tagId" IN (SELECT "Tag"."id" FROM "Tag" WHERE "Tag"."name" = $1))`
475
-
476
- > **Note:** Wrap JSON fields with `Json<T>` to get autocompletion for valid dot-notation paths.
477
-
478
- ### Aggregate Queries
78
+ > **Imperative API:** `defineEntity(User, { fields: { id: { type: 'uuid', isId: true } }, ... })`. No decorators needed. See [Imperative Definition](https://uql-orm.dev/entities/imperative).
479
79
 
480
- Use `querier.aggregate()` for `GROUP BY` analytics with `$count`, `$sum`, `$avg`, `$min`, `$max`, and full `$having` support.
80
+ ## Querying
481
81
 
482
82
  ```ts
483
- const results = await querier.aggregate(Order, {
484
- $group: {
485
- status: true,
486
- total: { $sum: 'amount' },
487
- count: { $count: '*' },
488
- },
489
- $having: { count: { $gt: 5 } },
490
- $sort: { total: -1 },
83
+ await querier.findMany(User, {
84
+ $select: { id: true, name: true },
85
+ $where: { email: { $endsWith: '@uql-orm.dev' } },
491
86
  $limit: 10,
492
87
  });
493
88
  ```
494
89
 
495
- **Generated SQL (PostgreSQL):**
90
+ 25+ comparison operators (`$eq`, `$in`, `$between`, `$like`, `$elemMatch`), logical operators (`$and`, `$or`, `$not`, `$nor`), and type-safe JSON/JSONB dot-notation queries.
496
91
 
497
- ```sql
498
- SELECT "status", SUM("amount") "total", COUNT(*) "count"
499
- FROM "Order"
500
- GROUP BY "status"
501
- HAVING COUNT(*) > $1
502
- ORDER BY SUM("amount") DESC
503
- LIMIT 10
504
- ```
505
-
506
- For `SELECT DISTINCT`, add `$distinct: true` to any find query:
507
-
508
- ```ts
509
- const names = await querier.findMany(User, {
510
- $select: { name: true },
511
- $distinct: true,
512
- });
513
- // → SELECT DISTINCT "name" FROM "User"
514
- ```
515
-
516
- > **Learn more**: See the full [Aggregate Queries guide](https://uql-orm.dev/querying/aggregate) for `$having` operators, MongoDB pipeline details, and advanced patterns.
517
-
518
- ### Cursor-Based Streaming
519
-
520
- For large result sets, use `findManyStream()` to iterate row-by-row without loading everything into memory. Each driver uses its optimal native cursor API.
521
-
522
- ```ts
523
- for await (const user of querier.findManyStream(User, { $where: { active: true } })) {
524
- process.stdout.write(JSON.stringify(user) + '\n');
525
- }
526
- ```
92
+ > [Querying](https://uql-orm.dev/querying/querier) · [Operators](https://uql-orm.dev/querying/comparison-operators) · [JSON](https://uql-orm.dev/querying/json)
527
93
 
528
- ### Thread-Safe Transactions
94
+ ## Transactions
529
95
 
530
- UQL is one of the few ORMs with a **centralized serialization engine**. Transactions are guaranteed to be race-condition free.
531
-
532
- #### Option A: Manual (Functional)
96
+ Functional `pool.transaction()` or `@Transactional()` decorator with centralized serialization:
533
97
 
534
98
  ```ts
535
- const result = await pool.transaction(async (querier) => {
536
- const user = await querier.findOne(User, { $where: { email: '...' } });
537
- await querier.insertOne(Profile, { userId: user.id, bio: '...' });
99
+ const userId = await pool.transaction(async (q) => {
100
+ const id = await q.insertOne(User, { email: 'a@b.com' });
101
+ await q.insertOne(Profile, { userId: id, bio: '...' });
102
+ return id;
538
103
  });
539
104
  ```
540
105
 
541
- #### Option B: Declarative (Decorators)
542
-
543
- Perfect for **NestJS** and other Dependency Injection frameworks. Use `@Transactional()` to wrap a method and `@InjectQuerier()` to access the managed connection.
544
-
545
- ```ts
546
- import { Transactional, InjectQuerier, type Querier } from 'uql-orm';
547
-
548
- export class UserService {
549
- @Transactional()
550
- async register({picture, ...user}: UserProfile, @InjectQuerier() querier?: Querier) {
551
- const userId = await querier.insertOne(User, user);
552
- await querier.insertOne(Profile, { userId, picture });
553
- }
554
- }
555
- ```
556
-
557
- #### Option C: Imperative
558
-
559
- For granular control over the transaction lifecycle, manage `begin`, `commit`, `rollback`, and `release` yourself.
560
-
561
- ```ts
562
- const querier = await pool.getQuerier();
563
- try {
564
- await querier.beginTransaction();
565
-
566
- const userId = await querier.insertOne(User, { name: '...' });
567
- await querier.insertOne(Profile, { userId, picture: '...' });
568
-
569
- await querier.commitTransaction();
570
- } catch (error) {
571
- await querier.rollbackTransaction();
572
- throw error;
573
- } finally {
574
- await querier.release();
575
- }
576
- ```
577
-
578
- ## 5. Migrations & Synchronization
106
+ ## Migrations
579
107
 
580
- UQL takes an **Entity-First** approach. You modify your TypeScript classes, and UQL handles the heavy lifting—auto-generating migration files by diffing your code against the live database.
108
+ Entity-first migrations: modify TypeScript classes, UQL auto-generates DDL by diffing code against the live database:
581
109
 
582
110
  ```bash
583
- # 1. Update your entity (add a field, change a type, etc.)
584
- # 2. Auto-generate the migration
585
- npx uql-migrate generate:entities add_user_nickname
586
-
587
- # 3. Review and apply
588
- npx uql-migrate up
589
- ```
590
-
591
- > **Note:** Keep entities as the source of truth to minimize drift between code and database schema.
592
-
593
- **Generated `generate:entities` files** emit **one `await querier.run("…")` per SQL statement** (table vs indexes, etc.), with the SQL passed as a **double-quoted string literal** (`JSON.stringify`) so dialects that quote identifiers with **backticks** (SQLite, LibSQL, MySQL-style) do not produce invalid TypeScript.
594
-
595
- If you implement a **custom `SchemaGenerator`**, note that **`generateCreateTable`**, **`generateCreateTableFromNode`**, and **`generateCreateTableFromDefinition`** return **`string[]`** (one entry per `querier.run`). Use **`.join('\n')`** only when you need a single combined script. See the **[changelog](CHANGELOG.md)** for **0.8.2**.
596
-
597
- **Advanced:** custom tools can use **`acquireQuerierForMigrations(pool)`** from **`uql-orm/migrate`** to match the same connection choice as **`Migrator`** and **`DatabaseMigrationStorage`** (including optional **`pool.getMigrationQuerier`**).
598
-
599
- ### 1. Unified Configuration
600
-
601
- Reuse the same `uql.config.ts` for your app and the CLI to ensure consistent settings (naming strategies, entities, pool):
602
-
603
- ```ts
604
- // uql.config.ts
605
- import type { Config } from 'uql-orm';
606
- import { PgQuerierPool } from 'uql-orm/postgres';
607
- import { User, Profile, Post } from './entities';
608
-
609
- export default {
610
- pool: new PgQuerierPool({ /* ... */ }),
611
- entities: [User, Profile, Post],
612
- migrationsPath: './migrations',
613
- } satisfies Config;
111
+ npx uql-migrate generate:entities add_user_nickname # generate from entities
112
+ npx uql-migrate up # apply
113
+ npx uql-migrate drift:check # detect drift
614
114
  ```
615
115
 
616
- ### 2. Manage via CLI
617
-
618
- Use the CLI to manage your database schema evolution.
619
-
620
- | Command | Description |
621
- | :--- | :--- |
622
- | `generate:entities <name>` | **Auto-generates** a migration by diffing your entities against the current DB schema. |
623
- | `generate <name>` | Creates an empty timestamped file for **manual** SQL migrations (e.g., data backfills). |
624
- | `generate:from-db` | **Scaffolds Entities** from an existing database. Includes **Smart Relation Detection**. |
625
- | `drift:check` | **Drift Detection**: Compares your defined entities against the actual database schema and reports discrepancies. |
626
- | `up` | Applies all pending migrations. |
627
- | `down` | Rolls back the last applied migration batch. |
628
- | `status` | Shows which migrations have been executed and which are pending. |
629
-
630
- #### Usage Examples
631
-
632
- ```bash
633
- # 1. Auto-generate schema changes from your entities
634
- npx uql-migrate generate:entities add_profile_table
635
-
636
- # 2. Apply changes
637
- npx uql-migrate up
638
-
639
- # 3. Check for schema drift (Production Safety)
640
- npx uql-migrate drift:check
641
-
642
- # 4. Scaffold entities from an existing DB (Legacy Adoption)
643
- npx uql-migrate generate:from-db --output ./src/entities
644
-
645
- # 5. Create a manual migration (for data backfills or custom SQL)
646
- npx uql-migrate generate seed_default_roles
647
- ```
648
-
649
- > **Bun Users**: If your `uql.config.ts` uses TypeScript path aliases (e.g., `~app/...`), run migrations with the `--bun` flag to ensure proper resolution:
650
- > ```bash
651
- > bun run --bun uql-migrate status
652
- > ```
653
- > Or add a script to your `package.json`: `"uql": "bun run --bun uql-migrate"`, then run commands like, e.g., `bun run uql status`.
654
-
655
- ### 3. AutoSync (Development)
656
-
657
- Keep your schema in sync without manual migrations. It is **safe by default**: in safe mode (default), it adds new tables/columns and blocks destructive changes (e.g., dropping a column or changing a `VARCHAR` to an `INTEGER`). Blocked actions are logged so you can migrate them manually.
658
-
659
- **New Capabilities (v3.8+):**
660
-
661
- * **Schema AST Engine**: Uses a graph-based representation of your schema for 100% accurate diffing, handling circular dependencies and correct topological sort orders for table creation/dropping.
662
- * **Smart Relation Detection**: When generating entities from an existing DB, UQL automatically detects relationships (OneToOne, ManyToMany) via foreign key structures and naming conventions (`user_id` -> `User`).
663
- * **Bidirectional Index Sync**: Indexes defined in `@Field({ index: true })` or `@Index()` are synced to the DB, and indexes found in the DB are reflected in generated entities.
664
-
665
- > **Important**: For `autoSync` to detect your entities, they must be **loaded** (imported) before calling `autoSync`.
666
-
667
- **Using Your Config (Recommended)**
668
-
669
- If you follow the [unified configuration](#1-unified-configuration) pattern, your entities are already imported. Simply reuse it:
670
-
671
- ```ts
672
- import { Migrator } from 'uql-orm/migrate';
673
- import config from './uql.config.js';
674
-
675
- const migrator = new Migrator(config.pool, {
676
- entities: config.entities,
677
- });
678
- await migrator.autoSync({ logging: true });
679
- ```
680
-
681
- **Explicit Entities**
682
-
683
- Alternatively, pass entities directly if you want to be explicit about which entities to sync:
684
-
685
- ```ts
686
- import { Migrator } from 'uql-orm/migrate';
687
- import { User, Profile, Post } from './entities/index.js';
688
-
689
- const migrator = new Migrator(pool, {
690
- entities: [User, Profile, Post],
691
- });
692
- await migrator.autoSync({ logging: true });
693
- ```
694
-
695
- > **Note:** In development, `autoSync` accelerates iteration while still protecting data by blocking destructive schema changes.
696
-
697
- ## 6. Operations
698
-
699
- ### 6.1 Logging & Monitoring
700
-
701
- UQL includes a structured logging system for query visibility and performance monitoring.
702
-
703
- ### Log Levels
704
-
705
- | Level | Description |
706
- | :-------------------- | :-------------------------------------------------------------------------------------- |
707
- | `query` | **Standard Queries**: Beautifully formatted SQL/Command logs with execution time. |
708
- | `slowQuery` | **Bottleneck Alerts**: Dedicated logging for queries exceeding your threshold. Use `logParams: false` to omit sensitive data. |
709
- | `error` / `warn` | **System Health**: Detailed error traces and potential issue warnings. |
710
- | `migration` | **Audit Trail**: Step-by-step history of schema changes. |
711
- | `skippedMigration` | **Safety**: Logs blocked unsafe schema changes during autoSync. |
712
- | `schema` / `info` | **Lifecycle**: Informative logs about ORM initialization and sync events. |
713
-
714
- ### Visual Feedback
715
-
716
- The `DefaultLogger` provides high-contrast, colored output for quick debugging:
717
-
718
- ```text
719
- query: SELECT * FROM "user" WHERE "id" = $1 -- [123] [2ms]
720
- slow query: UPDATE "post" SET "title" = $1 -- ["New Title"] [1250ms]
721
- error: Failed to connect to database: Connection timeout
722
- ```
723
-
724
- > **Note:** In production, keep logs lean with `logger: ['error', 'warn', 'slowQuery']`.
725
-
726
- Learn more about UQL at [uql-orm.dev](https://uql-orm.dev) for details on:
116
+ Safe `autoSync()` mode adds new tables/columns and blocks destructive changes in development.
727
117
 
728
- - [Complex Logical Operators](https://uql-orm.dev/querying/logical-operators)
729
- - [Aggregate Queries (GROUP BY, HAVING, DISTINCT)](https://uql-orm.dev/querying/aggregate)
730
- - [Semantic Search (Vector Similarity)](https://uql-orm.dev/querying/semantic-search)
731
- - [Relationship Mapping (1-1, 1-M, M-M)](https://uql-orm.dev/querying/relations)
732
- - [Lifecycle Hooks](https://uql-orm.dev/entities/lifecycle-hooks)
733
- - [Soft Deletes &amp; Auditing](https://uql-orm.dev/entities/soft-delete)
734
- - [Database Migration &amp; Syncing](https://uql-orm.dev/migrations)
118
+ > [Migrations](https://uql-orm.dev/migrations)
735
119
 
736
- ### Deep Dive: Tests & Technical Resources
120
+ ---
737
121
 
738
- For those who want to see the "engine under the hood," check out these resources in the source code:
122
+ ## Made with UQL
739
123
 
740
- - **Entity Mocks**: See how complex entities and virtual fields are defined in [entityMock.ts](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/test/entityMock.ts).
741
- - **Core Dialect Logic**: The foundation of our context-aware SQL generation in [abstractSqlDialect.ts](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/dialect/abstractSqlDialect.ts).
742
- - **Comprehensive Test Suite**:
743
- - [Abstract SQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/dialect/abstractSqlDialect-spec.ts): Base test suite for all dialects.
744
- - [PostgreSQL](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/postgres/postgresDialect.spec.ts) \| [MySQL](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/mysql/mysqlDialect.spec.ts) \| [SQLite](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/sqlite/sqliteDialect.spec.ts) specs.
745
- - [Querier Integration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/uql-orm/src/querier/abstractSqlQuerier-spec.ts): SQL generation & connection management tests.
124
+ ### [Variability.ai](https://variability.ai)
746
125
 
747
- ## Built with ❤️ and supported by
126
+ AI meeting recorder and video summarizer for Zoom, Meet, Teams, and more. Generates instant summaries with action items in 45+ languages.
748
127
 
749
- UQL is an open-source project proudly sponsored by **[Variability.ai](https://variability.ai)**.
128
+ [![Made with UQL](https://img.shields.io/badge/made%20with-UQL-6e6e6e?style=flat)](https://uql-orm.dev)