how to fully update a document in mongodb code example

Example 1: mongodb update

db.collectionName.update({"aField":"vale1"},{$set:{"anotherField":"value2"}})

-search for documentations for more examples than search
-aField is used to find the documents
-anotherField is the field that will be updated
-You can also use the below:
-- updateOne
-- findOneAndUpdate

Example 2: how to update subdocument mongodb

db.getCollection('products')
.update({"reviews.user": ObjectId("5f6e2e0b70eb0208fc8401a1")}, 
{$set: {"reviews.$.rating": NumberInt(3)}})