Hello everyone!
I've been struggling to implement a trigger that adds the timestamp of a relation's creation as its property. I've seen this post and I found it really useful, where after changing the syntax to my neo4j version (Community 4.0.0) I made it work with newly created nodes using this trigger:
CALL apoc.trigger.add('node_add_time',"UNWIND $createdNodes AS n
SET n.creation_date = apoc.date.format(timestamp())", {phase:'after'})
Here is the trigger where I've tried to do the same with relations but didn't work:
CALL apoc.trigger.add("rel_add_time", "UNWIND $createdRelationships AS rel
SET rel.creation_date = apoc.date.format(timestamp())", {phase:'after'})
The problem I've been facing is the fact that the relations are created, but the query gets stuck loading in the browser, and the properties are not set. I've tried a couple of example queries that are run over a db that already has 300k nodes and 600k rels, I don't know if this has something to do, but here are the examples that I've been using to test (The browser gets stuck executing the second query).
CREATE(node : MYNODE { name : 'node1'}) CREATE(node2 : MYNODE { name : 'node2'})
match (node : MYNODE) match (node2 : MYNODE) where node2 <> node merge (node)<-[:TEST]-(node2)
The label MYNODE is not previously in the DB, this 2 are the only occurences.
If you have any suggestion on what could be going wrong or if you have any other implementation that you think could do the job better than this one I'm all ears!
Thanks for you time.
PD: My APOC version is 4.0.0.2