[英]Create a Counter in Arango Query
I'm trying to create a counter from 1 to n in an Arango query. 我正在尝试在Arango查询中创建一个从1到n的计数器。 Basically, I need to group objects by a number in that range, and return the count of the objects in each group.
基本上,我需要按该范围内的数字对对象进行分组,然后返回每个组中对象的计数。 I had hoped creating a for loop would work, but it doesn't seem to be incrementing.
我曾希望创建一个for循环可以用,但是似乎并没有增加。 I'm unsure about the syntax.
我不确定语法。
The two loop I've tried are: 我尝试过的两个循环是:
FOR count IN [0,1,2,3]
and 和
FOR count IN 0..12
Those are the correct syntax to creating a counter loop. 这些是创建计数器循环的正确语法。
The reason why it didn't seem to work for me was because I put the return statement containing the count variable in the sub-loop. 它对我似乎不起作用的原因是因为我将包含count变量的return语句放在了子循环中。 It works when it is in the outer loop, like so:
当它在外循环中时,它可以工作,如下所示:
FOR count IN 0..12
LET total = COUNT (
FOR v, e IN OUTBOUND "some-object" GRAPH "some-graph"
RETURN 1
)
RETURN {total: total, count: count}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.