MongoDB – Update Document:

In MongoDB, updating a document can be done through below provided methods.

Syntax:

This command will update a single document even though the filter or condition have multiple document that may match to update.

This command will update all documents that match the condition.

This command will replace a single document that match the condition.

This command can update either a single document or multiple documents that match the condition.

Example: