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?
Asked
Active
Viewed 40 times
3

Max Yari
- 3,617
- 5
- 32
- 56
1 Answers
2
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

Brian Underwood
- 10,746
- 1
- 22
- 34
-
so there is no way to have direct feed from db transaction like matched/created count and workaround is to store this useless fields? – Max Yari Dec 04 '15 at 16:39
-
It's a good question. I don't know of a way, but there might be one. I would argue that the `created_at` is useless, though. By default many DB libraries store `created_at` and `updated_at` fields and you generally don't use them at first, but they often come in handy in debugging. – Brian Underwood Dec 04 '15 at 16:45
-
I was too fast calling them 'useless', yes, on the second thought they may indeed come in handy not only in this case. Thanks for the answer, Brian! Will go after it. – Max Yari Dec 04 '15 at 16:48
-
Cool ;) I agree it feels like a workaround. I'd also like a better answer – Brian Underwood Dec 04 '15 at 17:34