Home > database >  Django query mongo, query the nested sort the smallest a data in a document
Django query mongo, query the nested sort the smallest a data in a document

Time:09-30

Data structure is as follows:
The first data:
{
"_id" : ObjectId (" 599 b8d4bc92d640da0ba6a76 "),
"OPERATION_LIST" : [
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b70",
"OPERATION_TIME" : ISODate (" the 2017-08-22 T09:47:55. 479 z "),
"RANK" : 1,

},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b71",
"OPERATION_TIME" : ISODate (" the 2017-08-22 T09: that is, 518 z "),
"RANK" : 1,

},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b72",
"OPERATION_TIME" : ISODate (" the 2017-08-22 T09: ". 183 z "),
"RANK" : 1,

},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b70",
"RANK" : 1,

}
],

}
Article 2 the term "data
{
"_id" : ObjectId (" 59941 bfcc92d6415ecbc17b5 "),
"OPERATION_LIST" : [
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b70",
"RANK" : 1,
},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b71",
"RANK" : 2,

},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b73",
"RANK" : 3
},
{
"OPERATOR" : "593 f9cec57cb5a39a0d27b74",
"OPERATION_TIME" : ISODate (" the 2017-08-21 T17:02:21. 636 z "),
"RANK" : 1
},
{
"OPERATOR" : "593 f9c5c57cb5a39a0d27b6d",
"RANK" : 4
}
],
"SIGNER" : [],
"PROOFREADER" : [],
"SEAL_PERSON" : [],
"DISTRIBUTOR" : [],
"FILING_PERSON" : [],
"PLATE_MAKER" : [],
"STATUS" : 0
}

,,,,,,,
Nested query document statement as follows, but what I want is at the same time RANK (sort of) the youngest, but nested in the document how to achieve the smallest a
Q3=Q (__raw__={" OPERATION_LIST ": {" $elemMatch" : {" OPERATOR ": data. The get (" accountId"), "OPERATION_TIME" : {" $exists ": False}}}})

CodePudding user response:

The building Lord problem solving have no? I also met the same problem!
  • Related