Max Yari
Max Yari

Reputation: 3697

After query execution detect that merge created node, not matched

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?

Upvotes: 3

Views: 47

Answers (1)

Brian Underwood
Brian Underwood

Reputation: 10856

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

Upvotes: 2

Related Questions