metal-orm 1.0.73 → 1.0.74
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/README.md +10 -10
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/decorators/bootstrap.ts +49 -32
- package/src/decorators/index.ts +12 -12
package/README.md
CHANGED
|
@@ -549,16 +549,16 @@ const [user] = await selectFromEntity(User)
|
|
|
549
549
|
.where(eq(U.id, 1))
|
|
550
550
|
.execute(session); // user is an actual instance of the User class!
|
|
551
551
|
|
|
552
|
-
// Use executePlain() if you want raw POJOs instead of class instances
|
|
553
|
-
const [rawUser] = await selectFromEntity(User).executePlain(session);
|
|
554
|
-
|
|
555
|
-
user.posts.add({ title: 'From decorators' });
|
|
556
|
-
await session.commit();
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
Note: relation helpers like `add`/`attach` are only available on tracked entities returned by `execute(session)`. `executePlain()` returns POJOs without relation wrappers. Make sure the primary key (e.g. `id`) is selected so relation adds can link correctly.
|
|
560
|
-
|
|
561
|
-
Tip: to keep selections terse, use `select`, `include` (with `columns`), or the `sel`/`esel` helpers instead of spelling `table.columns.*` over and over. By default, `selectFromEntity` selects all columns if you don't specify any.
|
|
552
|
+
// Use executePlain() if you want raw POJOs instead of class instances
|
|
553
|
+
const [rawUser] = await selectFromEntity(User).executePlain(session);
|
|
554
|
+
|
|
555
|
+
user.posts.add({ title: 'From decorators' });
|
|
556
|
+
await session.commit();
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Note: relation helpers like `add`/`attach` are only available on tracked entities returned by `execute(session)`. `executePlain()` returns POJOs without relation wrappers. Make sure the primary key (e.g. `id`) is selected so relation adds can link correctly.
|
|
560
|
+
|
|
561
|
+
Tip: to keep selections terse, use `select`, `include` (with `columns`), or the `sel`/`esel` helpers instead of spelling `table.columns.*` over and over. By default, `selectFromEntity` selects all columns if you don't specify any.
|
|
562
562
|
|
|
563
563
|
|
|
564
564
|
This level is nice when:
|
package/dist/index.cjs
CHANGED
|
@@ -144,6 +144,7 @@ __export(index_exports, {
|
|
|
144
144
|
div: () => div,
|
|
145
145
|
endOfMonth: () => endOfMonth,
|
|
146
146
|
entityRef: () => entityRef,
|
|
147
|
+
entityRefs: () => entityRefs,
|
|
147
148
|
eq: () => eq,
|
|
148
149
|
esel: () => esel,
|
|
149
150
|
executeHydrated: () => executeHydrated,
|
|
@@ -7932,6 +7933,9 @@ var entityRef = (ctor) => {
|
|
|
7932
7933
|
}
|
|
7933
7934
|
return tableRef(table);
|
|
7934
7935
|
};
|
|
7936
|
+
var entityRefs = (...ctors) => {
|
|
7937
|
+
return ctors.map((ctor) => entityRef(ctor));
|
|
7938
|
+
};
|
|
7935
7939
|
|
|
7936
7940
|
// src/query-builder/select-helpers.ts
|
|
7937
7941
|
function sel(table, ...cols) {
|
|
@@ -13359,6 +13363,7 @@ function createPooledExecutorFactory(opts) {
|
|
|
13359
13363
|
div,
|
|
13360
13364
|
endOfMonth,
|
|
13361
13365
|
entityRef,
|
|
13366
|
+
entityRefs,
|
|
13362
13367
|
eq,
|
|
13363
13368
|
esel,
|
|
13364
13369
|
executeHydrated,
|