metal-orm 1.0.2 → 1.0.4

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 (37) hide show
  1. package/README.md +20 -0
  2. package/package.json +1 -1
  3. package/src/ast/expression.ts +433 -175
  4. package/src/ast/join.ts +8 -1
  5. package/src/ast/query.ts +64 -9
  6. package/src/builder/hydration-manager.ts +42 -11
  7. package/src/builder/hydration-planner.ts +80 -31
  8. package/src/builder/operations/column-selector.ts +37 -1
  9. package/src/builder/operations/cte-manager.ts +16 -0
  10. package/src/builder/operations/filter-manager.ts +32 -0
  11. package/src/builder/operations/join-manager.ts +17 -7
  12. package/src/builder/operations/pagination-manager.ts +19 -0
  13. package/src/builder/operations/relation-manager.ts +58 -3
  14. package/src/builder/query-ast-service.ts +100 -29
  15. package/src/builder/relation-conditions.ts +30 -1
  16. package/src/builder/relation-projection-helper.ts +43 -1
  17. package/src/builder/relation-service.ts +68 -13
  18. package/src/builder/relation-types.ts +6 -0
  19. package/src/builder/select-query-builder-deps.ts +64 -3
  20. package/src/builder/select-query-state.ts +72 -0
  21. package/src/builder/select.ts +166 -0
  22. package/src/codegen/typescript.ts +142 -44
  23. package/src/constants/sql-operator-config.ts +36 -0
  24. package/src/constants/sql.ts +125 -58
  25. package/src/dialect/abstract.ts +97 -22
  26. package/src/dialect/mssql/index.ts +27 -0
  27. package/src/dialect/mysql/index.ts +22 -0
  28. package/src/dialect/postgres/index.ts +22 -0
  29. package/src/dialect/sqlite/index.ts +22 -0
  30. package/src/runtime/als.ts +15 -1
  31. package/src/runtime/hydration.ts +20 -15
  32. package/src/schema/column.ts +45 -5
  33. package/src/schema/relation.ts +49 -2
  34. package/src/schema/table.ts +27 -3
  35. package/src/utils/join-node.ts +20 -0
  36. package/src/utils/raw-column-parser.ts +32 -0
  37. package/src/utils/relation-alias.ts +43 -0
package/README.md CHANGED
@@ -84,6 +84,26 @@ const hydrated = hydrateRows(rows as Record<string, unknown>[], builder.getHydra
84
84
  console.log(hydrated);
85
85
  ```
86
86
 
87
+ ## Helper idea
88
+
89
+ If you find yourself compiling/executing the same way across your app, wrap the compiler + driver interaction in a tiny helper instead of repeating it:
90
+
91
+ ```typescript
92
+ async function runMetalQuery<T>(
93
+ builder: SelectQueryBuilder<T>,
94
+ connection: mysql.Connection,
95
+ dialect = new MySqlDialect()
96
+ ) {
97
+ const { sql, params } = builder.compile(dialect);
98
+ const [rows] = await connection.execute(sql, params);
99
+ return hydrateRows(rows as Record<string, unknown>[], builder.getHydrationPlan());
100
+ }
101
+
102
+ const results = await runMetalQuery(builder, connection);
103
+ ```
104
+
105
+ This keeps the ORM-focused pieces in one place while letting you reuse any pooling/transaction strategy the driver provides.
106
+
87
107
  ## Contributing
88
108
 
89
109
  We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metal-orm",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {