Reputation: 3
I want to do a query in OrientDB but i don't know how it works.
I'm using the Graph API and my DB looks like this:
class(V): @route (Name, Start, Length, Goal)
class(V): @direction (Goal, length)
class(E): @has_A class(E): @start_Direction class(E): @has_Follower
The Edges are connected to the Vertices like this:
route -> has_A -> direction
route -> start_Direction -> direction
direction -> has_Follower -> direction
now i need to find all followers by the name of the route, what works so far is when i enter a rid (of the class startDirection) directly to the query for example:
select * from (traverse outE('has_Follower'),has_Follower.in from #??:?) where @class='direction'
But now i need to get to the rid over the Name of the route (which is the problem), what i tried so far is:
select * from (traverse outE('has_Follower'),has_Follower.in from (select @rid from start_Direction where start_Direction.out = (select @rid from route where Name = 'nameOfroute'))) where @class='direction'
But this gives me an empty query, although when i type in the rid from start_Direction of which i know has a has_Follower it works.
Hope this is understandable, thanks for any help in advance.
Upvotes: 0
Views: 412
Reputation: 2814
One problem in your query is probably start_Direction.out = (select...
, you have to use an IN
instead of an =
, eg start_Direction.out IN (select...
.
In general, I think the easiest way to do what you need is as follows:
MATCH
{class:route, as:route} -start_Direction-> {} -has_Follower-> {as:direction, while:(true)}
RETURN route.@rid, route.Name, route.Start, route.Length, route.Goal, direction.Goal, direction.length
Or just RETURN $elements
if you want single records per row
Upvotes: 0