metal-orm 1.0.4 → 1.0.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.
- package/docs/hydration.md +10 -1
- package/package.json +1 -1
- package/src/ast/expression.ts +632 -614
- package/src/ast/query.ts +110 -49
- package/src/builder/delete-query-state.ts +42 -0
- package/src/builder/delete.ts +57 -0
- package/src/builder/hydration-manager.ts +3 -2
- package/src/builder/hydration-planner.ts +89 -33
- package/src/builder/insert-query-state.ts +62 -0
- package/src/builder/insert.ts +59 -0
- package/src/builder/operations/relation-manager.ts +1 -23
- package/src/builder/relation-conditions.ts +45 -1
- package/src/builder/relation-service.ts +81 -18
- package/src/builder/relation-types.ts +15 -0
- package/src/builder/relation-utils.ts +12 -0
- package/src/builder/select.ts +2 -1
- package/src/builder/update-query-state.ts +59 -0
- package/src/builder/update.ts +61 -0
- package/src/dialect/abstract.ts +107 -47
- package/src/dialect/mssql/index.ts +31 -6
- package/src/dialect/mysql/index.ts +31 -6
- package/src/dialect/postgres/index.ts +45 -6
- package/src/dialect/sqlite/index.ts +45 -6
- package/src/index.ts +6 -3
- package/src/playground/features/playground/data/scenarios/hydration.ts +23 -11
- package/src/playground/features/playground/data/schema.ts +10 -6
- package/src/runtime/hydration.ts +17 -5
- package/src/schema/relation.ts +59 -18
- package/tests/belongs-to-many.test.ts +57 -0
- package/tests/dml.test.ts +206 -0
package/docs/hydration.md
CHANGED
|
@@ -38,4 +38,13 @@ const hydrated = hydrateRows(rows, builder.getHydrationPlan());
|
|
|
38
38
|
|
|
39
39
|
## How it Works
|
|
40
40
|
|
|
41
|
-
The `SelectQueryBuilder` analyzes the `include()` configuration and generates a `HydrationPlan`. This plan contains the necessary information to map the flat rows to a nested structure, including relation details and column aliases. The `hydrateRows()` function then uses this plan to efficiently process the result set.
|
|
41
|
+
The `SelectQueryBuilder` analyzes the `include()` configuration and generates a `HydrationPlan`. This plan contains the necessary information to map the flat rows to a nested structure, including relation details and column aliases. The `hydrateRows()` function then uses this plan to efficiently process the result set.
|
|
42
|
+
|
|
43
|
+
For belongs-to-many relationships you can also request pivot columns via the `pivot` option. Pivot columns are hydrated alongside each child row under the `_pivot` key, e.g.:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
.include('projects', {
|
|
47
|
+
columns: ['id', 'name', 'client'],
|
|
48
|
+
pivot: { columns: ['assigned_at', 'role_id'] }
|
|
49
|
+
})
|
|
50
|
+
```
|