I was wondering if this the correct way to make a trigger
CALL apoc.trigger.add(
'setCreatedProperty',
'UNWIND $createdNodes AS n SET n.created = timestamp()',
{phase: "afterAsync"}
)
Yesterday I accidentally noticed one of my test nodes does not have this created field.
╒═════════════════════════════════════════════╕
│n │
╞═════════════════════════════════════════════╡
│(:Person {created: 1740608142752,name: "p1"})│
├─────────────────────────────────────────────┤
│(:Person {name: "p2"}) │
├─────────────────────────────────────────────┤
│(:Person {created: 1740608155923,name: "p3"})│
├─────────────────────────────────────────────┤
│(:Person {created: 1740608230117,name: "p4"})│
├─────────────────────────────────────────────┤
│(:Person {created: 1740608237464,name: "p5"})│
└─────────────────────────────────────────────┘
There is a bit of disclaimer here, as I am also testing with adding nodes through a plugin. But I guess on the other hand that should not be allowed to mess up this trigger behaviour.