@strapi/database 5.0.0-rc.15 → 5.0.0-rc.17
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.js
CHANGED
|
@@ -3473,7 +3473,11 @@ const oneToMany = async (input, ctx) => {
|
|
|
3473
3473
|
const { db, qb } = ctx;
|
|
3474
3474
|
const fromTargetRow = (rowOrRows) => fromRow(targetMeta, rowOrRows);
|
|
3475
3475
|
if ("joinColumn" in attribute && attribute.joinColumn) {
|
|
3476
|
-
const {
|
|
3476
|
+
const {
|
|
3477
|
+
name: joinColumnName,
|
|
3478
|
+
referencedColumn: referencedColumnName,
|
|
3479
|
+
on
|
|
3480
|
+
} = attribute.joinColumn;
|
|
3477
3481
|
const referencedValues = ___default.default.uniq(
|
|
3478
3482
|
results.map((r) => r[joinColumnName]).filter((value) => !___default.default.isNil(value))
|
|
3479
3483
|
);
|
|
@@ -3483,7 +3487,10 @@ const oneToMany = async (input, ctx) => {
|
|
|
3483
3487
|
});
|
|
3484
3488
|
return;
|
|
3485
3489
|
}
|
|
3486
|
-
const rows = await db.entityManager.createQueryBuilder(targetMeta.uid).init(populateValue).addSelect(`${qb.alias}.${referencedColumnName}`).where({
|
|
3490
|
+
const rows = await db.entityManager.createQueryBuilder(targetMeta.uid).init(populateValue).addSelect(`${qb.alias}.${referencedColumnName}`).where({
|
|
3491
|
+
[referencedColumnName]: referencedValues,
|
|
3492
|
+
...on && typeof on === "function" ? on({ populateValue, results }) : {}
|
|
3493
|
+
}).execute({ mapResults: false });
|
|
3487
3494
|
const map = ___default.default.groupBy(referencedColumnName)(rows);
|
|
3488
3495
|
results.forEach((result) => {
|
|
3489
3496
|
result[attributeName] = fromTargetRow(map[result[joinColumnName]] || []);
|