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
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!
data
andfrequency
(multiple times), but it's not allowed (not side-effect free). AQL is not a full programming language, and this is on purpose: queries can be optimized a lot because of AQL's inherent limitations. There are usually pure AQL solutions though, using sub-queries for instance. – CodeManX