how to update a whole document in mongodb code example
Example 1: mongodb update a data in database
db.Employee.update(
{"Employeeid" : 1},
{$set: { "EmployeeName" : "NewMartin"}});
Example 2: how to update subdocument mongodb
db.getCollection('products')
.update({"reviews.user": ObjectId("5f6e2e0b70eb0208fc8401a1")},
{$set: {"reviews.$.rating": NumberInt(3)}})