取代整份文件
你收藏中的《Aladdin》條目內容已過時。有人請你將它完整換成 2019 年上映的新版資訊。為此,你會使用 .replace_one(),用新的文件直接取代整份舊文件。
本練習屬於課程
Python 中的 MongoDB 入門
練習說明
- 建立
query_filter,用標題比對原版《Aladdin》電影。 - 完成
aladdin_new的定義,將"release_year"設為2019。 - 以新的文件覆寫舊的文件。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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)