Reputation: 3228
Lets say i have these nodes with these relations (A,B) are nodes
and Rs are Relation Names
:
A-R1->B
A-R2->B
A-R3->B
Now i do not actually know if one or any R
has relation between these 2 nodes. how can i specify if any relation exists between these 2 nodes regardless of knowing what relation is it?
Also if there are any relation exists between these two nodes is it possible to know what relation is it?
Upvotes: 0
Views: 2631
Reputation: 16355
how can i specify if any relation exists between these 2 nodes regardless of knowing what relation is it?
I believe that a simple MATCH will be sufficient. The below query returns all relationships between a node named "A" and a node named "B", if exists.
MATCH ({name : "A"})-[r]->({name : "B"})
RETURN r
Also if there are any relation exists between these two nodes is it possible to know what relation is it?
The type() function returns a string representation of the relationship type. Then the below query will return the string representing the type of each relationship between A and B.
MATCH ({name : "A"})-[r]->({name : "B"})
RETURN type(r) as type
Upvotes: 2