metal-orm 1.0.96 → 1.0.98
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/dist/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/hydration/types.ts +57 -57
- package/src/orm/entity-relations.ts +19 -19
- package/src/orm/hydration.ts +9 -1
- package/src/orm/lazy-batch/belongs-to-many.ts +134 -134
- package/src/orm/lazy-batch/belongs-to.ts +108 -108
- package/src/orm/lazy-batch/has-many.ts +69 -69
- package/src/orm/lazy-batch/has-one.ts +68 -68
- package/src/orm/lazy-batch/shared.ts +125 -125
- package/src/orm/save-graph.ts +48 -48
- package/src/query-builder/column-selector.ts +9 -9
- package/src/query-builder/hydration-manager.ts +353 -353
- package/src/query-builder/hydration-planner.ts +22 -22
- package/src/query-builder/relation-conditions.ts +80 -80
- package/src/query-builder/select/projection-facet.ts +23 -23
- package/src/query-builder/select-query-state.ts +213 -213
- package/src/query-builder/select.ts +1155 -1133
- package/src/schema/relation.ts +22 -22
package/dist/index.cjs
CHANGED
|
@@ -5058,9 +5058,15 @@ var hydrateRows = (rows, plan) => {
|
|
|
5058
5058
|
}
|
|
5059
5059
|
return seen;
|
|
5060
5060
|
};
|
|
5061
|
+
const hasRelations = plan.relations.length > 0;
|
|
5061
5062
|
for (const row of rows) {
|
|
5062
5063
|
const rootId = row[plan.rootPrimaryKey];
|
|
5063
|
-
if (rootId === void 0)
|
|
5064
|
+
if (rootId === void 0 || rootId === null) {
|
|
5065
|
+
if (!hasRelations) {
|
|
5066
|
+
rootMap.set(Symbol(), createBaseRow(row, plan));
|
|
5067
|
+
}
|
|
5068
|
+
continue;
|
|
5069
|
+
}
|
|
5064
5070
|
const parent = getOrCreateParent(row);
|
|
5065
5071
|
if (!parent) continue;
|
|
5066
5072
|
for (const rel of plan.relations) {
|
|
@@ -7577,6 +7583,24 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
7577
7583
|
const builder = this.ensureDefaultSelection();
|
|
7578
7584
|
return executePagedQuery(builder, session, options, (sess) => builder.count(sess));
|
|
7579
7585
|
}
|
|
7586
|
+
/**
|
|
7587
|
+
* Executes the query and returns an array of values for a single column.
|
|
7588
|
+
* This is a convenience method to avoid manual `.map(r => r.column)`.
|
|
7589
|
+
*
|
|
7590
|
+
* @param column - The column name to extract
|
|
7591
|
+
* @param ctx - ORM session context
|
|
7592
|
+
* @returns Promise of an array containing only the values of the specified column
|
|
7593
|
+
* @example
|
|
7594
|
+
* const acronyms = await selectFromEntity(Organization)
|
|
7595
|
+
* .select('acronym')
|
|
7596
|
+
* .distinct(O.acronym)
|
|
7597
|
+
* .pluck('acronym', session);
|
|
7598
|
+
* // ['NASA', 'UN', 'WHO']
|
|
7599
|
+
*/
|
|
7600
|
+
async pluck(column, ctx) {
|
|
7601
|
+
const rows = await this.executePlain(ctx);
|
|
7602
|
+
return rows.map((r) => r[column]);
|
|
7603
|
+
}
|
|
7580
7604
|
/**
|
|
7581
7605
|
* Executes the query with provided execution and hydration contexts
|
|
7582
7606
|
* @param execCtx - Execution context
|