【发布时间】:2019-11-14 04:33:38
【问题描述】:
我需要有关如何根据嵌套文档对 mongodb 查询进行排序的帮助
这是我尝试过的
$options = ['sort' => ['stats' => ['points' => 1]]];
$query = new MongoDB\Driver\Query([],$options);
这是 mongo 对象的架构
{
"_id" : ObjectId("5d0cd19c811d53277225fc33"),
"uuid" : "a2277fa1-07df-4c19-902a-93ae7e2795a1",
"name" : "ImAleex_",
"stats" : {
"points" : 1000,
"kills" : 1,
"losses" : 1,
"wins" : 1
},
"info" : {
"lastRankeds" : NumberLong(1561128665478),
"lastConnection" : NumberLong(1561128834286),
"lastModifiedKit" : NumberLong(1561215124553),
"rankeds" : 5,
"visibility" : true,
"chat" : true,
"fly" : false,
"requests" : true,
"menuRequests" : true
}
}
我在 Apache 日志中收到此错误消息 ConnectionException:错误的排序规范
【问题讨论】: