我有两个嵌入式文档和列表字段的视图,需要filteringquery
以下标准:
class myfriends(EmbeddedDocument):
myfriends_ids = StringField()
status = StringField()
class Friends(Document):
friend1 = ReferenceField(User)
myfriendslist = ListField(EmbeddedDocumentField(myfriends))
存储的值就像:
{ "_id" : ObjectId("542506f9bed069156ddd4476"),
"friend1" : ObjectId("542314b7bed0691c5302662c"),
"myfriendslist" : [
{
"myfriends_ids" : "5421ae74bed0691471e95b92",
"status" : "1"
} ]
}
我希望查询根据django mongoengine中的friend1
和myfriends_ids
获取特定记录。
答案 0 :(得分:0)
Friends.objects(myfriendslist__match={"myfriends_ids": "5421ae74bed0691471e95b92", "status": "1"}, friend1=FriendObject)