【发布时间】:2021-04-07 05:24:41
【问题描述】:
所以我的 MongoDB 集合中有这种类型的文档:
{
"_id" : ObjectId("606c66c875a2fe6153bfc71f"),
"t_id" : "12345678a",
"r_id" : "r12345678a",
"t_e_stats" : {
"acc" : "70"
},
"register_time" : ISODate("2021-04-06T19:18:56.890Z")
}
这些文档中有多个具有相同的“t_id”和不同的“t_e_stats”字典。但是所有 't_e_stats' 字典中都有 'acc' 键。现在我想在 't_e_stats' 字典中查询具有最大值 'acc' 的特定 't_id' 的条目。我如何在 MongoEngine 中做到这一点?或者我发现也有在 MongoEngine 中运行 PyMongo 查询的方法,如果可能的话如何使用?
【问题讨论】:
标签: python-3.x mongodb mongodb-query mongoengine