Get startedGet started for free

Deleting multiple MongoDB documents

It's time for some database cleanup. More specifically, you're going to use .delete_many() to delete all movies that were released a long time ago, in one go.

This exercise is part of the course

Introduction to MongoDB in Python

View Course

Exercise instructions

  • Delete all movies that have a "release_year" before 1990.
  • Print the number of deleted documents.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from pymongo import MongoClient 
client = MongoClient()
mov = client.film.movies

# Delete all movies released before 1990
res = ____

# Print the number of deleted documents
print(____)
Edit and Run Code