Apoc procedure - Trigger ID and increment
closed
a.cavallo@outlook.it
which is the correct APoc procedure to Trigger an ID and Increment it +1 every time I call a create?
Assuming User has an ID - my idea is to increment using ID and not UUID.
CALL apoc.trigger.add('create-event-gen-id',"UNWIND {createdNodes} AS e
MATCH (n:User)
Do you think this one is correct?
thank you.
John Kennedy
closed
John Kennedy
Thanks Oren Goldberg, I'm moving this one to the questions section.
Oren Goldberg
Sorry this isn't the answer you are looking for, but I highly recommend you use UUIDs instead of integers for the purpose of ids. Here's some documentation on how: https://neo4j.com/labs/apoc/4.1/graph-updates/uuid/#automatic-uuids
a.cavallo@outlook.it
Oren Goldberg: Thank you but this was the correct query:
"UNWIND $createdNodes AS e
MATCH(n:User)
with e, MAX(n.ID) as maxId
Set e.ID = maxId + 1"
But the fact that I have to make a MATCH again to retrieve the USER with the ID incremented I think is something missing in APOC , I should get back the User with the new Triggered ID...