Reputation: 105
I'm interested in using traversals to quickly find all the documents linked to an initial document. For this I'd use:
let id = 'documents/18787898'
for d in documents
filter d._id == id
for i in 1..1 any d edges
return i
This generally provides me with all the documents related to the initial ones. However, say that in these edges I have more information than just the standard _from
and _to
. Say it also contains order
, in which I indicate the order in which something is to be displayed. Is there a way to also grab that information at the same time as making the traversal? Or do I now have to make a completely separate query for that information?
Upvotes: 0
Views: 267
Reputation: 767
You are very close, but your graph traversal is slightly incorrect.
The way I read the documentation, it shows that you can return vertex
, edge
, and path
objects in a traversal:
FOR vertex[, edge[, path]]
IN [min[..max]]
OUTBOUND|INBOUND|ANY startVertex
edgeCollection1, ..., edgeCollectionN
I suggest adding the edge variable e
to your FOR
statement, and you do not need to find document/vertex matches first (given than id
is a single string), so the FOR
/FILTER
pair can be eliminated:
LET id = 'documents/18787898'
FOR v, e IN 1 ANY id edges
RETURN e
Upvotes: 2