0

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!

dan674
  • 1,848
  • 2
  • 15
  • 21

0 Answers0