我需要更新mongodb集合中的所有内容,并将其替换为空值{},
def update(database, collection, data):
client = Mongongoclient
with client:
db = client[database]
db[collection].update_many({},{"$set":data})
dict = {}
update("db", "collection",dict )
但是当我运行程序时,它会返回以下错误:
raise WriteError(error.get("errmsg"), error.get("code"), error)
pymongo.errors.WriteError: Modifiers operate on fields