MongoDb - How can I update multiple elements of a nested object using $set?
You can update by using the following:
db.myCollection.update({
name: 'mydoc'
}, {
$set: {
'nestedDoc.b': 20,
'nestedDoc.c': 30,
'nestedDoc.d': 40
}
})
Here is more information about update command:
- Update Documents