I have the following document:
{
"_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"
}
My problem is I will create an aggregate query that only outputs the ranking object elements with sorting. I have created the following aggregate query but how can I sort the elements of the object?
[{$match: {
"server-id": 137680026513571840
}}, {$project: {
"_id": 0, "ranking": 1
}}]
Expected output:
{
"137913231757803520":10430.560000000001,
"137679488392757248":15.039999999999997,
"142705222618185728":6,
"137865769668050945":0
}
rankingfield should be an array, instead of object?