Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-22-2021 09:43 AM
Hello guys,
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, I know maybe is not performant but I have to.
The perfect thing to me should be triggering the ID but as the MAX-ID ( something like maxId + 1 )
CALL apoc.trigger.add('create-event-gen-id',"UNWIND {createdNodes} AS e
MATCH (n:User)
set e.ID=e.ID + 1", {phase:'after'});
Can you help me ?
Thank you, for you're time.
I really appreciate!!
Solved! Go to Solution.
10-25-2021 08:58 AM
You may like something like:
CALL apoc.trigger.add('create-event-gen-id',"UNWIND $createdNodes AS e
MATCH(n:User)
with e MAX(n.ID) as maxId
Set e.ID = maxId + 1", {phase:'before'})
It's important to notice that if you create somethin' new. You don't see the property inside the CREATE response. You need to execute a MATCH after it in order to retrieve the info.
Bennu
10-25-2021 08:58 AM
You may like something like:
CALL apoc.trigger.add('create-event-gen-id',"UNWIND $createdNodes AS e
MATCH(n:User)
with e MAX(n.ID) as maxId
Set e.ID = maxId + 1", {phase:'before'})
It's important to notice that if you create somethin' new. You don't see the property inside the CREATE response. You need to execute a MATCH after it in order to retrieve the info.
Bennu
All the sessions of the conference are now available online