I have a complex structure of JSON object which contain (N) number of embedded arrays. A single entry is an object with two fields : @name
and content
. I need to filter them in projection stage (without using $unwind
) to get one specific object where @name
field is equals to specific value:
productCategory: {$filter: {
input: '$characteristics.attributeGroup.attribute',
as: 'attribute',
cond: {
...?
}}
The $characteristics.attributeGroup.attribute
input returns the above structure. I was trying to use something like that in $cond: { $eq: ['$$attribute.@name', 'averageRating'] }
but it doesn't work.
Could you please help me to find out a solution here?
Thanks in advance!