在 mongoengine 中更新嵌入的文档 [英] Updating an embedded document in mongoengine
本文介绍了在 mongoengine 中更新嵌入的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 mongoengine 课程
I have a class in mongoengine
class Post(EmbeddedDocument):
uid = StringField(required=True)
text = StringField(required=True)
value = StringField()
class Feed(Document):
label = StringField(required=True)
feed_url = StringField(required=True)
posts = ListField(EmbeddedDocumentField(Post))
我正在尝试从某个父"更新 Post EmbeddedDocument 属性名称文本.文档.作为第一步,我检索 Feed 文档
I am trying to update the Post EmbeddedDocument property name text from a certain "Parent" document. As a first step, I retrieve the Feed Document
model = Feed.objects(_id="....").first()
然后我想更新嵌入文档Post"的属性文本.
and then I want to update the property text of the embedded document "Post".
我怎样才能用 mongoengine 实现它?谢谢
How can I achieve it with mongoengine? Thanks
推荐答案
我解决了 :)
Feed.objects(_id="...", posts__text="findvalue").update(set__posts__S__value="updatevalue")
这篇关于在 mongoengine 中更新嵌入的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文