{
"offers" : [
{
"name" : "min",
"prices" : [
8, 15, 18
]
},
{
"name" : "max",
"prices" : [
9, 11, 18
]
}
],
"nl" : [
2, 4, 6, 7
]
}
update aggregation not working $in. I have tried on the two ways
[
{
$set: {
offers: {
$cond: {
if: {
"nl": {$in: [7]}
},
then: {
$concatArrays: ["$offers", []]
},
else: {
$concatArrays: ["$offers", [{
"name" : "minimal",
"prices" : []
}]]
}
}
}
}
},
]
The code below is not working and not showing any error.
[
{
$set: {
offers: {
$cond: {
if: {
$in: ["$nl", 7]
},
then: {
$concatArrays: ["$offers", []]
},
else: {
$concatArrays: ["$offers", [{
"name" : "minimal",
"prices" : []
}]]
}
}
}
}
},
]
I want to cancat with offers array according to the exi/stence of 7 in the field "nl". Please help me. I am trying to solve this problem during 5 hours.