22.数组简约式

可以构建一个新的简约数组用于查询结果的构建.

下边的例子我们建立一个新的数组包含所有孩子的名字。

Query:

SELECT 
    fname AS parent_name,
    ARRAY child.fname FOR child IN tutorial.children END AS child_names
        FROM tutorial 
            WHERE children IS NOT NULL

结果:

{
  "results": [
    {
      "child_names": [
        "Aiden",
        "Bill"
      ],
      "parent_name": "Dave"
    },
    {
      "child_names": [
        "Xena",
        "Yuri"
      ],
      "parent_name": "Earl"
    },
    {
      "child_names": [
        "Abama",
        "Bebama"
      ],
      "parent_name": "Ian"
    }
  ]
}

Last updated

Was this helpful?