Discuss Update Methods in MongoDB?

Updating documents from the collection has two methods:
a)updateOne(filter,update,option)
b) updateMany(filter,update,option).

Both methods accept filters and options optionally where the filter is used to filter the documents for finding and the option is used to perform additional tasks.

With updateOne() we can update a single document of a collection. If we pass a filter for updateOne() it will update the first matched document.

db.collectionName.updateOne(filter,update,option)

With updateMany() we can update all the documents from the collection. If we pass the filter to updateMany(), it will update all the documents that matched the filter.

db.collectionName.updateMany(filter,update,option)