The $exists operator
Take a moment and run list(mov.find()): you'll find that some movies have a box_office field while others do not. Let's get a better understanding of the situation.
Bu egzersiz
Introduction to MongoDB in Python
kursunun bir parçasıdırEgzersiz talimatları
- Find all the documents where the
box_officefield exists and store the resulting cursor object asbox_curs. - Turn the cursor object into a Python list and store it as
box.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Find all documents where box_office is set
box_curs = mov.find({
"____": {
"____": ____
}
})
# Convert from cursor to list
box = ____
print(box)
print(f"{len(box)}/{mov.count_documents({})} movies have the box_office field.")