Hey there,
I have a problem with merging objects to the root level while using deep population.
My schema looks like that:
[
{
title: {
de: "Test",
en: "test"
},
infos: [
{
label: {
de: "Test",
en: "test"
},
data: [
{
label: {
de: "Test",
en: "test"
}
},
],
}
],
}
]
When using the aggregation function everything working fine with this syntax. I’m getting the following response when I execute:
title: `$title.${languageCode}`,
description: `$description.${languageCode}`,
infos: {
$map: {
input: '$infos',
in: {
$mergeObjects: [
'$$this',
{
label: `$$this.label.${languageCode}`,
},
{
data: {
$map: {
input: '$$this.data',
as: 'data',
in: {
$mergeObjects: [
'$$data',
{
label: `$$data.label.${languageCode}`,
},
{
description: `$$data.description.${languageCode}`,
},
],
},
},
},
},
],
},
},
},
}```
The response looks as expected like that:
title 'Test'
....
So I merge the right language and only display that string.
Now to my actual problem. When I'm using deep population, so:
{
path: 'exercises.exercise',
select: ExerciseProtection.DEFAULT(languageCode),
populate: ExercisePopulate.DEFAULT(languageCode), -> includes the projection showing above
},
The "infos" were merged correctly but title and description are not anymore in the results.
If I change the projection: title: '$title.en' to someOtherTile: '$title.en' the "someOtherTitle" is displayed in the results.
Does someone has an idea why when I use title it is not displayed in the results but when using someOtherTitle it is in the results?
Thanks!