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

Inserting multiple documents

Sometimes, you need to add multiple documents at once—instead of calling .insert_one() over and over. MongoDB's .insert_many() lets you do just that.

Bu egzersiz

Introduction to MongoDB in Python

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

Egzersiz talimatları

  • Finalize the definition of new_movies by setting the titles: "arrival" and "m3gan", respectively.
  • Insert the movies into the movies collection of the film database.
  • Print out the auto-generated ids of the newly inserted document.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Complete definition of new_movies
new_movies = [
    {
      "title": ____,
      "genre": ["mystery", "sci-fi"],
      "release_year": 2016, "rating": 7.9
    },
    {
		"title": ____,
		"genre": ["horror", "sci-fi", "thriller"],
		"release_year": 2023, "rating": 6.4
  }
]

# Insert new movies
res = ____

# Print out the auto-generated ids
print(___)
Kodu Düzenle ve Çalıştır