The user model has an array of notifications, which each have a "read" property (true or false). I'm trying to update "read" on all of these to "true". Here's my code:
db.User.findOneAndUpdate(
{ _id: req.token._id },
{ $set: { "notifications.$[].read" : true } }
)
And the error I get:
"name": "MongoError",
"message": "cannot use the part (notifications of notifications.$[].read) to traverse the element...
I'm using mongoose. Any ideas? Thanks!