문서 삭제

Python으로 배우는 MongoDB 입문

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
Python으로 배우는 MongoDB 입문

여러 문서 한꺼번에 삭제

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

# How many documents deleted? res.deleted_count
4
  • 문서 삭제는 영구적이며 복구할 수 없습니다!
  • 삭제 전 필터를 꼭 다시 확인하세요!
Python으로 배우는 MongoDB 입문

연습해 봅시다!

Python으로 배우는 MongoDB 입문

Preparing Video For Download...