我想对结果进行排序,但是arango忽略了我的aql请求。
以我的查询为例
FOR d IN system_menu
SORT d.Lvl DESC
SORT d.Submenu[*].Lvl DESC
RETURN d
d.Lvl是一个INT值。如何在文档中对文档的数组进行排序?
我的文档:
{
"System": {},
"Controller": "reports",
"Show": true,
"Icon": "mdi-newspaper",
"Lvl": 3,
"Title": {
"DEde": "Berichte",
"Universal": "Reports"
},
"Submenu": [
{
"Title": {
"DEde": "Tätigkeitsberichte",
"Universal": "Activity reports"
},
"Controller": "activity-reports",
"Tabmenu": "",
"Filter": "",
"Lvl": 2,
"Show": true,
"Hrule": false
},
{
"Title": {
"DEde": "Behördenbericht",
"Universal": "Authority reports"
},
"Controller": "request-data-subject",
"Tabmenu": "",
"Filter": "",
"Lvl": 1,
"Show": true,
"Hrule": false
},
{
"Title": {
"DEde": "Auskunftsersuchen",
"Universal": "Request from a data subject"
},
"Controller": "request-data-subject",
"Tabmenu": "",
"Filter": "",
"Lvl": 3,
"Show": true,
"Hrule": false
}
]
}
排序不起作用!如何从1 ... 100开始按INT排序所有文档?
答案 0 :(得分:1)
要对内部数组进行排序,您可以使用内部循环,例如
FOR d IN system_menu
SORT d.Lvl DESC
LET submenus = (
FOR s IN d.Submenu
SORT s.Lvl DESC
RETURN s
)
RETURN MERGE(d, { Submenu: submenus })