March 2019
Intermediate to advanced
394 pages
11h 4m
English
In the following code block, you can see an example of updating a single document using the update_one helper method.
This operation matches one document in the search phase and modifies one document based on the operation to be applied to the matched documents:
>>> result = books.update_one({"isbn": "101"}, {"$set": {"price": 100}})>>> print(result.matched_count)1>>> print(result.modified_count)1
In a similar way to inserting documents, when updating documents, we can use update_one or update_many:
Read now
Unlock full access