@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.mjs CHANGED
@@ -3441,7 +3441,11 @@ const oneToMany = async (input, ctx) => {
3441
3441
  const { db, qb } = ctx;
3442
3442
  const fromTargetRow = (rowOrRows) => fromRow(targetMeta, rowOrRows);
3443
3443
  if ("joinColumn" in attribute && attribute.joinColumn) {
3444
- const { name: joinColumnName, referencedColumn: referencedColumnName } = attribute.joinColumn;
3444
+ const {
3445
+ name: joinColumnName,
3446
+ referencedColumn: referencedColumnName,
3447
+ on
3448
+ } = attribute.joinColumn;
3445
3449
  const referencedValues = _.uniq(
3446
3450
  results.map((r) => r[joinColumnName]).filter((value) => !_.isNil(value))
3447
3451
  );
@@ -3451,7 +3455,10 @@ const oneToMany = async (input, ctx) => {
3451
3455
  });
3452
3456
  return;
3453
3457
  }
3454
- const rows = await db.entityManager.createQueryBuilder(targetMeta.uid).init(populateValue).addSelect(`${qb.alias}.${referencedColumnName}`).where({ [referencedColumnName]: referencedValues }).execute({ mapResults: false });
3458
+ const rows = await db.entityManager.createQueryBuilder(targetMeta.uid).init(populateValue).addSelect(`${qb.alias}.${referencedColumnName}`).where({
3459
+ [referencedColumnName]: referencedValues,
3460
+ ...on && typeof on === "function" ? on({ populateValue, results }) : {}
3461
+ }).execute({ mapResults: false });
3455
3462
  const map2 = _.groupBy(referencedColumnName)(rows);
3456
3463
  results.forEach((result) => {
3457
3464
  result[attributeName] = fromTargetRow(map2[result[joinColumnName]] || []);