After query execution detect that merge created node, not matched

51 Views Asked by At

Simple question, that I'm having hard time googling. Using cypher via node-neo4j, I want to run some logic after query, but only if my MERGE created node (i.e ON CREATE inside query was triggered), not matched it. How can I achieve this?

1

There are 1 best solutions below

4
On BEST ANSWER

You could have created_at and matched_at fields with MERGE and then check them for equality when you return the object:

MERGE (f:Foo)
ON CREATE SET f.created_at = timestamp()
ON MATCH SET f.matched_at = timestamp()
RETURN f