I have a graph with nodes like 'Persons' and relationships called 'RELATION' with a dynamic type like 'BIOLOGICAL_MOTHER'.
To check if a person is in a parent-role i want to use one cypher-query that return one boolean row, instead of NULL or something else.
I use Spring Data Neo4j 4 and this is the following method in the person-repository:
@Query("OPTIONAL MATCH (child)-[r:RELATION]->(parent) " +
"RETURN DISTINCT " +
"CASE " +
"WHEN id(parent)={0} AND r IS NOT NULL AND (r.type='BIOLOGICAL_MOTHER' OR r.type='BIOLOGICAL_FATHER') " +
"THEN true " +
"ELSE false " +
"END")
boolean isParentRole(long id);
If i query this on a parent person, the following error returns :
More than one element in org.neo4j.helpers.collection.IterableWrapper
$MyIteratorWrapper@235ecd9f.
First element is 'true' and the second element is 'false'
How can i use "OR" of all result-rows, to return only one row (in this case true)?