I need to create a relation between two users once, and update its properties since then. Is there a way to do something like "create if not exist otherwise update" in Neo4j using Cypher?
MERGE (u1:User)-[r:REL]->(u2:User)
ON CREATE SET
u1.prop1 = val1,
u2.prop2 = val2,
r.prop3 = val3
ON MATCH SET
u1.prop1 = newVal1,
u2.prop2 = newVal2,
r.prop3 = newVal3
Have a look at the Neo4j docs for "MERGE".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With