1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to MongoDB in Python

Connected

Exercise

Retrieving documents using .find()

One common way of retrieving documents from a MongoDB collection is .find(). When called on a collection, it will return a cursor object pointing to all records or all records that match a specified filter query. Using list() you can actually fetch the documents, and go from a cursor object to a Python list.

Instructions

100 XP
  • Create a variable mov that holds the movies collection instance in the film database.
  • Fetch all movies in the collection and store it in all_movies as a Python list.
  • Fetch all movies in the collection that have a release_year equal to 2008 as a Python list.