mongodb find and update array item by id
db.myCollection.update({"_id" : 1, "lb.id" : 2},{$set : {"lb.$.sc" : 17}})
mongodb find and update array item by id
db.myCollection.update({"_id" : 1, "lb.id" : 2},{$set : {"lb.$.sc" : 17}})
mongodb update all items in array
// If array field not in find, use $[]
db.products.updateMany({}, {
$set:{ "variants.$[]._id": new ObjectId() }
})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us