Search code examples
orientdb

OrientDb check if edge exists in one direction


I am using orientdb and i am expanding all those vertices which are following me. Now i am also following some of the vertices so I want to check if i am following a particular vertex or not.

The query i am using:

SELECT @rid, name FROM (SELECT expand(in('Follow')) FROM users WHERE @rid = #123:8 LIMIT 20)

And i have tried to do

SELECT @rid as userRid, name, if(SELECT FROM follow where out = #123:8 And in = userRid, 1, 0) as followed FROM (SELECT expand(in('follow')) FROM users WHERE @rid = #123:8 LIMIT 20)

Any idea how to achieve the expected results?


Solution

  • Try this:

    select from <your rid> where out('Follow').@rid contains <person rid>
    

    Hope it helps

    Regards