user22866
user22866

Reputation: 255

With arangodb AQB how do you get out/inEdges an from/toVertices? in a query?

Suppose the following query from fluent query interface thats removed as of v3.x:

var tens = graph._vertices(lst).outEdges().restrict("knows").toVertices()
.inEdges().restrict("works").fromVertices().inEdges().restrict("owns")
.fromVertices().toArray();

here lst is a simply a list of vertices obtained from a prior query, and the vertices in lst may have outgoing edge relationships one of which is of type knows, and the vertices pointed to by these outEdges have incoming edges of type works in turn,

how would this be written with AQB? the two (AQB and fluent query interface are supposed to overlap and thats why one was removed). Iv looked at the documentation on github but im not seeing anything that would help with a query like the one above

Upvotes: 0

Views: 46

Answers (2)

Alan Plum
Alan Plum

Reputation: 10892

You're correct that this can't be represented in AQB. We're currently in the process of deprecating AQB in favour of the aql template handler supported by both the JavaScript driver (arangojs) and ArangoDB 2.8 and later: https://docs.arangodb.com/3.11/develop/javascript-api/@arangodb/#the-aql-template-tag

With the template string handler it is possible to write arbitrary AQL queries in ArangoDB 3. If I understand it correctly, your fluent query should translate to something like this:

db._query(aql`
  FOR vertex IN ${lst}
  FOR v1 IN OUTBOUND vertex knows
  FOR v2 IN INBOUND v1 works
  FOR v3 IN INBOUND v2 owns
  RETURN v3
`).toArray()

Upvotes: 1

user22866
user22866

Reputation: 255

This is what i have worked out so far:

db._query("FOR vrt0 in @lst FOR vrt1  in OUTBOUND vrt0 knows FOR vrt2 in 
INBOUND vrt1 works  FOR vrt3 in INBOUND vrt2 owns RETURN vtr3",{"@lst": lst });

The information retrieved is equivalent to what i would expect from the corresponding fluent query interface.

Upvotes: 1

Related Questions