From the course: MongoDB Python Developer Associate Cert Prep

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Updating documents in Python applications

Updating documents in Python applications

- Hello. In this video, you'll learn how to perform single and multiple document updates in MongoDB with a Python application by using PyMongo's update one and update many methods. You'll learn how to update the value of an existing field and how to define a new field and value in an update. First, let's update a single document by using the update one method. We use the update one method when we need to update a single document that matches some specified criteria. The syntax for update one is db.collection.update_one. Update one has two required arguments, a filter document that specifies the selection criteria and an update document that specifies the modifications. To demonstrate update one, we'll work with a database named bank that contains an accounts collection. We want to increase the balance of a specific account by $100. Here's the document that contains the account that we need to update,…

Contents