I want to construct a query in cypher that does the following:
The compare and update part is something that I am not able to achieve in cypher. So any assistence on this part is greatly appreciated.
You need combine MERGE ON CREATE | ON MATCH
and CASE expression
. For example:
MATCH (A:City {id: 1})
MATCH (B:City {id: 2})
WITH A, B, toInteger(rand()*100) as newDuration
MERGE (A)-[r:next]->(B)
ON CREATE SET r.duration = newDuration
ON MATCH SET r.duration = CASE
WHEN r.duration > newDuration
THEN newDuration
ELSE r.duration
END
RETURN r.duration
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