1

我尝试通过“beginAt”属性对边缘迭代的结果进行排序,但它对我不起作用,遵循 aql 代码:

FOR f IN TRAVERSAL(client, careerEdges, "client/100", "outbound", {paths:true})

            let sorted = (
                FOR e IN f.path.edges
                    FILTER e.order <= 3
            SORT e.beginAt DESC
            RETURN e)

RETURN sorted

与“订单”属性相同。始终返回相同的序列,如下所示:

    [
  [],
  [
    {
      "_id": "careerEdges/240469605275",
      "_rev": "240469605275",
      "_key": "240469605275",
      "_from": "client/100",
      "_to": "careers/iniAlt",
      "order": 2,
      "$label": "noLonger",
      "beginAt": "2014-05-10 13:48:00",
      "endAt": "2014-07-20 13:48:00"
    }
  ],
  [
    {
      "_id": "careerEdges/240470064027",
      "_rev": "240470064027",
      "_key": "240470064027",
      "_from": "client/100",
      "_to": "careers/lidGru",
      "order": 3,
      "$label": "noLonger",
      "beginAt": "2014-07-20 13:48:00",
      "endAt": "2014-08-20 13:48:00"
    }
  ],
  [
    {
      "_id": "careerEdges/240469867419",
      "_rev": "240469867419",
      "_key": "240469867419",
      "_from": "client/100",
      "_to": "careers/iniEst",
      "endAt": null,
      "order": 1,
      "$label": "noLonger",
      "beginAt": "2014-06-10 13:48:00"
    }
  ]
]

我的查询正确吗?

4

1 回答 1

2

您的查询正在生成列表列表。内部列表将按 排序beginAt,但不是整体结果。

如果您想要返回一个平面列表并按某些标准对其进行排序,请尝试以下操作:

FOR f IN TRAVERSAL(client, careerEdges, "client/100", "outbound", {paths:true})
  FOR e IN f.path.edges
    FILTER e.order <= 3
    SORT e.beginAt DESC
    RETURN e
于 2014-11-28T21:51:28.837 回答