From the course: MongoDB Java Developer Associate Cert Prep

Unlock this course with a free trial

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

Querying on array elements in MongoDB

Querying on array elements in MongoDB

- Hello! In this video you'll learn how to update multiple documents in a single MongoDB collection by using the updateMany() method. The updateMany() method accepts a filter document, an update document and an options object. The options object is not required and we won't use it in this video. The filter document contains the selection criteria for the update. In this example, "year: 2022", is the filter document within the updateMany() method. The update document contains the modifications to apply to all documents that match the filter. Imagine that we want to update all the books in a collection that meets certain criteria. We can use the updateMany() method to do this. Here's one document from the Books collection. It includes information about a single book including fields like '_id', 'title', 'published date', 'status' and 'authors'. We'll use updateMany() to update all documents that were published before…

Contents