APOC triggers to automatically add properties

I am using an apoc trigger to automatically add a property to all newly created nodes.

call apoc.trigger.add('add_property', "unwind {createdNodes} as node match(node) set node.auto = 'property'", { phase: 'before' })

When I execute the following cypher query, I was expecting that the returned node already contain the 'auto' property.

CREATE(node : MYNODE { name : 'node1'}) RETURN node

But instead, I need to reload it to see the 'auto' property.

match(node : MYNODE { name : 'node1'}) RETURN node

Is this the normal behavior ? Is this possible to create a trigger that directly modify the returned node during the creation ?

Thanks for your help


neo4j 3.3.2

That's expected behaviour. When the transaction is about to be committed (the before phase) the results of your statement are already produced, so you won't see trigger modifications at that time.

1 Like