Update of object in MongoDB with node.js Update of object in MongoDB with node.js mongoose mongoose

Update of object in MongoDB with node.js


Something like this should work for you. Finds and replace the patient for the selected room.

department.findOneAndUpdate(    { "rooms.patient.patientnr": parseInt(req.params.id) },    { "$set": {"rooms.$.patient": patient}},    {new : true}    ....)