BaşlayınÜcretsiz Başlayın

Replacing an entire document

The Aladdin entry in your movie collection is outdated. You've been asked to replace it in full with a newer version of the film released in 2019. To do that, you'll use .replace_one(), which swaps the entire document with a new one.

Bu egzersiz

Introduction to MongoDB in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a query_filter to match the original Aladdin movie by title.
  • Complete the definition of aladdin_new by setting the "release_year" to 2019.
  • Overwrite the old document with the new one.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Specify the query_filter
query_filter = {
  ____: ____
}

# Complete the details of the new movie
aladdin_new = {
  "title": "aladdin",
  "genre": ["adventure", "comedy", "family"],
  "____": ____,
  "rating": 6.9
}

# Replace the old aladdin movie
res = ____
print(res)
Kodu Düzenle ve Çalıştır