Introduction to MongoDB in Python
Filip Schouwenaars
Machine Learning Researcher
# Setup from pymongo import MongoClient client = MongoClient() mov = client.film.movies# Delete document that matches filter, similar to find_one() res = mov.delete_one({ "title": "gladiator" })# How many documents were deleted? res.deleted_count
1
# Delete all really bad movies res = mov.delete_many({ "rating": { "$lt": 5.0 } })# How many documents deleted? res.deleted_count
4
Introduction to MongoDB in Python