I got this record structure
{
"_id" : "CAaveDCnPiC3KE6XS",
"user_id" : "3zjDhNBRMQPQSeTFa",
"notifs" : [
{
"to" : "3zjDhNBRMQPQSeTFa",
"from" : "cvatYfpebH4X45EvN",
"seen": false,
"postedAt" : 1431952371949.0000000000000000
},
{
"to" : "3zjDhNBRMQPQSeTFa",
"from" : "cvatYfpebH4X45EvN",
"seen": false,
"postedAt" : 1431952378382.0000000000000000
},
{
"to" : "3zjDhNBRMQPQSeTFa",
"from" : "cvatYfpebH4X45EvN",
"seen": true,
"postedAt" : 1431952378382.0000000000000000
}
}
I want to update all the seen
profperty inside notifs
property to true,
I can’t find How to do this, I tried few things nothing worked
Notifications.update({user_id: "sss"}, {$set: {"notifs.seen": true} });
Notifications.update({user_id:this.userId,'notifs.seen': {$ne: true} },{$set: {'notifs.$.seen': true}});
I have meteorhacks:aggregate
package installed, any aggregate solutions are also welcome
Note: $elemmatch
is not a solution because it updates only one object in array