0

ドキュメントとリスト フィールドが埋め込まれた 2 つのビューがあり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 に基づいて特定のレコードを取得するクエリが必要ですfriend1myfriends_ids

4

1 に答える 1

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