Answers for "mongodb update all items in array"

1

mongodb find and update array item by id

db.myCollection.update({"_id" : 1, "lb.id" : 2},{$set : {"lb.$.sc" : 17}})
Posted by: Guest on May-28-2021
0

mongodb update all items in array

// If array field not in find, use $[]
db.products.updateMany({}, {
  $set:{ "variants.$[]._id": new ObjectId() }
})
Posted by: Guest on January-17-2022

Code answers related to "mongodb update all items in array"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language