به روز رسانی بسیاری(Update Many)

برای به روز رسانی همه اسنادی که با معیارهای درخواست مطابقت دارند، از
روش update_many().




مثال


Update all documents where the address starts with the letter "S":



import pymongo

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

mydb = myclient["mydatabase"]
mycol = mydb["customers"]


myquery = { "address": { "$regex": "^S" } }
newvalues = { "$set": {
"name": "Minnie" } }


x = mycol.update_many(myquery, newvalues)

print(x.modified_count, "documents updated.")