Answers for "mongodb update object 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
-1

mongoose update array in object

Person.findOneAndUpdate({_id: id}, 
{ 
  "$set": {[`items.$[outer].${propertyName}`]: value} 
},
{ 
  "arrayFilters": [{ "outer.id": itemId }]
},
function(err, response) {
  ...
})
Posted by: Guest on January-11-2021

Code answers related to "mongodb update object in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language