mongoose updatemany change key code example
Example 1: mongodb change key name
db.students.updateMany( {}, { $rename: { "nmae": "name" } } )
Example 2: mongoose updatemany example
User.update({"created": false}, {"$set":{"created": true}}, {"multi": true}, (err, writeResult) => {});
Example 3: mongoose update array in object
Person.findOneAndUpdate({_id: id},
{
"$set": {[`items.$[outer].${propertyName}`]: value}
},
{
"arrayFilters": [{ "outer.id": itemId }]
},
function(err, response) {
...
})