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

Connected

Exercise

Deleting a single document

No collection stays perfect forever. Sometimes, you'll need to remove outdated, invalid, or unwanted entries. MongoDB makes this easy with .delete_one(), which removes the first matching document based on a filter. In this exercise, you'll remove the movie Casablanca from the collection. It's no longer needed in our dataset. No pre-written code is available this time; you've got this!

Instructions

100 XP
  • Delete the movie titled "casablanca" from the movies collection; make sure to use lower case.
  • Do a printout to verify that, indeed, one document got deleted.