Chirrut Imwe
Chirrut Imwe

Reputation: 673

How to select all nodes of a certain type connected via an Edge?

I am quite new to OrientDB, I have a Node labeled Resource, and i have other nodes labeled User and Administrator connected to it. I know I can Select all the Users who are "HasAccessTo" the Resource, like this:

SELECT in("HasAccessTo") FROM Resource 

But how do I write the Query if I want to Select only those who are labeled as User and not Administrator?

Thanks for the help in advance.

Upvotes: 1

Views: 368

Answers (1)

Luigi Dell'Aquila
Luigi Dell'Aquila

Reputation: 2814

Long answer:

 SELECT FROM (
   SELECT expand(in("HasAccessTo")) FROM Resource   
 ) WHERE @class = "User"

Short answer:

SELECT in("HasAccessTo")[@class = "User"] FROM Resource 

or (expanded)

SELECT expand(in("HasAccessTo")[@class = "User"]) FROM Resource 

Upvotes: 1

Related Questions