Search code examples
orientdbgraph-databases

Get all relationships connected to a node that are NOT of a particular class


So you can easily get all connections to a vertex that are of a particular class by querying

select from Foo where both() in (#42:1)

This will get all the vertices of class Foo that are connected to vertex #42:1 with either outbound or inbound links.

However what would be the query if I wanted to get all the vertices that are connected to #42:1 that are not instances of class Foo?

Does OrientDB natively support this functionality or would I have to do something like an intersection?


Solution

  • why not using

    SELECT * FROM (
    ... your select query
    )
    WHERE @class <> 'Foo'
    

    Another way could be represented by using Matching Expression

    MATCH
    {E, where:(@class <> 'Foo')}-your_relation->{class:Foo}
    RETURN E, F
    

    Rob