ComenzarEmpieza gratis

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!

Este ejercicio forma parte del curso

Introduction to MongoDB in Python

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

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

# Delete the movie titled "casablanca"
res = ____

# Do a printout to verify the deletion
print(____)
Editar y ejecutar código