I'm using Python to access my ArangoDB. Sometimes it would be useful to figure out if the result is empty or if I have exactly one result by using len(cursor)
.
This unfortunately leads mostly to an exception:
│arango.exceptions.CursorCountError: cursor count not enabled
In the source code of the cursor it seems there needs to be a count-variable in the resultset.
According to the documentation this is done by adding:
COLLECT WITH COUNT INTO length
In my case I'm using a simple, mostly automatically generated query filtering everything:
FOR i IN nodes
FILTER i.ID == "3000" OR i.ID == "3005" OR i.ID == "11235"
RETURN {'_id':i._id,'id':i.id}
Adding a COLLECT
is resulting in an error. This post https://stackoverflow.com/a/24131344/2516892 would suggest a solution like that:
FOR m IN nodes
FILTER m.ID == "3000" OR m.ID == "3005" OR m.ID == "11235"
COLLECT WITH COUNT INTO length
RETURN {'_id':i._id,'id':i.id, 'length': length}
Which is not working. What would be the correct query inserting this kind of aggregate function?