fix(richtext-*): hasMany relationships not populated correctly

This commit is contained in:
Alessio Gravili
2023-10-21 23:58:47 +02:00
parent 863b79348b
commit e197e0316f
2 changed files with 35 additions and 30 deletions

View File

@@ -76,21 +76,23 @@ export const recurseNestedFields = ({
data[field.name]?.value &&
data[field.name]?.relationTo
) {
const collection = req.payload.collections[data[field.name].relationTo]
promises.push(
populate({
id: data[field.name].value,
collection,
currentDepth,
data: data[field.name],
depth,
field,
key: 'value',
overrideAccess,
req,
showHiddenFields,
}),
)
if (!('hasMany' in field) || !field.hasMany) {
const collection = req.payload.collections[data[field.name].relationTo]
promises.push(
populate({
id: data[field.name].value,
collection,
currentDepth,
data: data[field.name],
depth,
field,
key: 'value',
overrideAccess,
req,
showHiddenFields,
}),
)
}
}
}
if (typeof data[field.name] !== 'undefined' && typeof field.relationTo === 'string') {