Mazání dokumentů

Introduction to MongoDB in Python

Filip Schouwenaars

Machine Learning Researcher

Smazání jednoho dokumentu

# 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
Introduction to MongoDB in Python

Odstranění více dokumentů najednou

# Delete all really bad movies
res = mov.delete_many({ "rating": { "$lt": 5.0 } })

# How many documents deleted? res.deleted_count
4
  • Mazání dokumentů je trvalé a nelze ho vrátit!
  • Před smazáním zkontrolujte filtry!
Introduction to MongoDB in Python

Lass uns üben!

Introduction to MongoDB in Python

Preparing Video For Download...