just stuck on how to filter the below document on the basis of user_id and popupsArray.isSeen = true.
I want to get the popups from popupsArray whose isSeen = FALSE
You can simply use the $filter in aggregation
db.collection.aggregate([
{
$set: {
popupsArray: {
"$filter": {
"input": "$popupsArray",
"cond": {
$eq: [
"$$this.isSeen",
false
]
}
}
}
}
}
])
Working Mongo playground