2014-09-26 121 views
0

我有嵌入的文档和列表字段两种观点,需要filteringquery 低于标准:过滤查询mongoengine

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中的friend1myfriends_ids获取具体记录。

回答

0
Friends.objects(myfriendslist__match={"myfriends_ids": "5421ae74bed0691471e95b92", "status": "1"}, friend1=FriendObject)