Python 是否有一种更新整个mongoengine文档的方法,只传递更新的类实例,而不是传递所有要更新的字段?

Python 是否有一种更新整个mongoengine文档的方法,只传递更新的类实例,而不是传递所有要更新的字段?,python,mongodb,mongoengine,Python,Mongodb,Mongoengine,让我们假设有一个mongoengine模型 class Post(Document): name = StringField() id = LongField() postContent = StringField() 假设mongodb数据库中存储了一个Post文档,我想更新多个字段。我知道我们可以做到 Post.objects(userId=user_id).update_one(name="updated_name", postContent=&

让我们假设有一个mongoengine模型

class Post(Document):
   name = StringField()
   id   = LongField()
   postContent = StringField()
假设mongodb数据库中存储了一个Post文档,我想更新多个字段。我知道我们可以做到

Post.objects(userId=user_id).update_one(name="updated_name", postContent="updated_content")
但我想像这样更新它

post = Post.objects(userId=1).get()
post.name=updated_name
post.content= updated_content
Post.objects(userId=1).update_one(post)
i、 我想更新整个文档而不单独传递字段。当我尝试这样做时,我犯了这个错误

ValueError: update only works with $ operators
有办法做到这一点吗