简体   繁体   中英

Create a Counter in Arango Query

I'm trying to create a counter from 1 to n in an Arango query. 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. 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. 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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM