Reputation: 281
What I want to achieve:
MERGE (p:Person {name: "David" OR id = 1}) SET p.age = 18 RETURN p;
Basically if one of the two condition match then set a 3rd property.
Upvotes: 0
Views: 81
Reputation: 9284
This is not possible via simple merge, one way to do it, is via apoc.do.when
function, like this:
OPTIONAL MATCH (p:Person)
WHERE p.name = "Dravid" OR p.id = 1
CALL apoc.do.when(p IS NULL, 'MERGE(p1:Person {name: "Dravid", id: 1}) RETURN p1', 'SET p.age = 18 RETURN p', {p: p})
YIELD value
RETURN value
Here, we first try to fetch the person, using name or id. If it's present, we set the age to 18, otherwise we create a new node.
Upvotes: 1