0

我有两个带有嵌入式文档和列表字段的视图,需要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 mongoenginefriend1的特定记录。myfriends_ids

4

1 回答 1

0
Friends.objects(myfriendslist__match={"myfriends_ids": "5421ae74bed0691471e95b92", "status": "1"}, friend1=FriendObject)
于 2015-05-11T13:56:10.387 回答