[英]Changing AQL so that sub-query result is flattened into two seperate arrays
This query works: 此查询有效:
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}
And gives me this: 并告诉我这个:
[
{
data: 18,
frequency: 69
},
{
data: 19,
frequency: 73
},
{
data: 20,
frequency: 86
}
]
But what i really want is something like this 但我真正想要的是这样的事情
{
data: [18, 19, 20]
frequency: [69, 73, 86]
}
I was expecting the following query to work - but the PUSH statements fail (syntax error), i tried a bunch of PUSH statements in FOR loops but can't get them to work as i expect, which would imply i am doing something absolutely mental 我期待以下查询工作 - 但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}
Any advice would be great! 任何建议都会很棒!
And, after some more fiddling - this seems to be exactly what I needed: 而且,经过一些更多的摆弄 - 这似乎正是我所需要的:
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}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.