MongoDB汇总问题排序对象字段

我有以下文件:

{
   "_id":{
      "$oid":"5e4d660e3b67ed11bce33b01"
   },
   "server-id":{
      "$numberLong":"137680026513571840"
   },
   "created":{
      "$date":"2020-02-19T16:45:02.536Z"
   },
   "prefixes":{
      "569494194964660224":{
         "displayname":"Admin",
         "placeholder":"%E2%9D%96"
      },
      "643867965313253385":{
         "displayname":"Mod",
         "placeholder":"%E2%9D%96"
      }
   },
   "module_permissions":{
      "ranking":true
   },
   "ranking":{
      "137679488392757248":15.039999999999997,
      "142705222618185728":6,
      "137865769668050945":0,
      "137913231757803520":10430.560000000001
   },
   "language":"de"
}

我的问题是我将创建一个聚合查询,该查询仅输出具有排序的排名对象元素。我创建了以下聚合查询,但是如何对对象的元素进行排序?

[{$match: {
  "server-id": 137680026513571840
}}, {$project: {
  "_id": 0, "ranking": 1
}}]
评论