此查询有效:
FOR person IN 1..1 INBOUND @companyID employed_by
LET age = DATE_DIFF(person.age * 1000, @currentTime * 1000, 'y')
COLLECT label = age WITH COUNT INTO value
RETURN {data: label, frequency: value}
并告诉我:
[
{
data: 18,
frequency: 69
},
{
data: 19,
frequency: 73
},
{
data: 20,
frequency: 86
}
]
但我真正想要的是这样的事情
{
data: [18, 19, 20]
frequency: [69, 73, 86]
}
我希望以下查询能够正常工作 - 但PUSH语句失败(语法错误),我在FOR循环中尝试了一堆PUSH语句,但无法让它按照我的预期工作,这意味着我在做绝对精神
LET data = []
LET frequency = []
LET temp =
(
FOR person IN 1..1 INBOUND @companyID employed_by
LET age = DATE_DIFF(person.age * 1000, @currentTime * 1000, 'y')
COLLECT label = age WITH COUNT INTO value
data = PUSH(data, label)
frequency = PUSH(frequency, value)
RETURN true
)
RETURN {data: data, frequency: frequency}
任何建议都会很棒!
答案 0 :(得分:3)
而且,经过一些更多的摆弄 - 这似乎正是我所需要的:
LET temp =
(
FOR person IN 1..1 INBOUND @companyID employed_by
LET age = DATE_DIFF(person.age * 1000, @currentTime * 1000, 'y')
COLLECT label = age WITH COUNT INTO value
RETURN {data: label, frequency: value}
)
RETURN {data: temp[*].data, frequency: temp[*].frequency}