Updating Arrays using $push & $each

db.movieDetails.updateOne ({title: “The Martian”}, { $push: { reviews: { $each: [ {rating: 0.5, date: (“2019-12-17T09:00:00Z”), reviewer: “Nat”, text: “reviewText2”}, {rating: 0.6, date: (“2019-12-17T10:00:00Z”), reviewer: “Tips”, text: “reviewText3”} ] } } })

{ “acknowledged” : true, “matchedCount” : 0, “modifiedCount” : 0 }

When I execute the above it doesn’t add to my array - not sure why - can you help?

The value of matchedCount indicates that no document matched the criteria title : "The Martian". It could be

  1. you are connected to the wrong cluster
  2. you are not using the correct database
  3. the movieDetails collection is missing some document
  4. the criteria might simply be wrong

Thanks - it was 2 - oops :blush:

Thanks @steevej-1495.

Hi @Lorna_75133,

I’m glad your issue got resolved. If you have any other query then please feel free to create another thread.

Shubham Ranjan
Curriculum Support Engineer