Search code examples
gremlingraph-databasestinkerpopamazon-neptune

Get a boolean value if an edge exsists in gremlin


I want to do a simple query in which I have a user and a group. Users have an edge "memberOf" to group vertex. Given a userId and a groupId, I want to write a query that returns true or false if there is an edge between the user and the group.


Solution

  • Just adding a second answer to mention that you can also use the hasNext step for this. It will return true or false depending on whether the target exists.

    g.V().hasId('userid').
          out().hasId('group1').
          hasNext()