model.updateOne(
{ _id: "abcxyz", "items._id": "deflmn" },
{
$set: {
"items.$.name": "new_name",
"items.$.value": "new_value",
}
}
)
Person.update(
{
_id: 5,
grades: { $elemMatch: { grade: { $lte: 90 }, mean: { $gt: 80 } } }
},
{ $set: { "grades.$.std" : 6 } }
)
db.inventory.updateOne(
{ _id: 2 },
{ $addToSet: { tags: { $each: [ "camera", "electronics", "accessories" ] } } }
)