cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Need to check relation properties dynamically if number of properties increases

Need to check where condition properties (u.id = c.id or u.name = c.name or u.add = lc.add) dynamically as the number properties will increase in future. lets say I want to accommodate another attribute status I need check that condition also  along with these. Could you please suggest on this.

below sample query I am using

match (c:child) with c match (u:User) with c,u where not (c)-[:LINK]->(u) and (u.id = c.id or u.name = c.name or u.add = lc.add) with c,u
merge (c)-[:LINK]->(u) return c
 
thanks in advance 🙂
1 REPLY 1

You can use the 'any' predicate for lists to implement an 'or' for all the properties.  The following query is testing if any of the properties of the child node equals the same property in the user node. If the properties of user node is not the same as the child node, then you may want to duplicate the condition one line for four the other way, to account for the different properties in the user node. 

match (c:child) 
match (u:User) 
where not exists((c)-[:LINK]->(u))
and any(i in keys(c) where c[i]=u[i])
merge (c)-[:LINK]->(u) 
return c