The core classes used for updates are update_one() and update_many(). The difference between the two is that the latter potentially affects multiple documents. Here is the generic syntax. The parameters in square brackets [] are optional:
update_one(<filter>, <update>, [<upsert>, \
<bypass_document_validation>, <collation>, \
<array_filters>, <session>])
The arguments match their mongo shell equivalents and are summarized here:
Parameter | Default | Notes |
filter | -- | A query dictionary that is identical to that used for the find() method. |
update | -- | A $set : { key / value pairs }Â dictionary, where the key corresponds to the field and the value is the updated information. |
upsert | False | If set to True, a new document is added if the query filter does not find a match. |
bypass_document_validation | False | If set to True, the write operation is instructed not to validate. This improves performance at the cost... |