查询简单的字符串数组

时间:2015-10-16 23:53:11

标签: couchbase n1ql

我有一个简单的查询:

SELECT container.category FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null

它给了我json:

[{
    "category": "0028H3:WV CUTTING EDGE AXIAL REAM TRAY"
},
{
    "category": "AVENTURA OASYS 1-2"
}, ... etc.

但是我需要一个扁平的字符串数组:

["0028H3:WV CUTTING EDGE AXIAL REAM TRAY",
 "AVENTURA OASYS 1-2",
   ... etc
]

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:3)

你可以使用ARRAY_AGG:

SELECT RAW ARRAY_AGG(container.category)
FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null