Currently, I'm making an application with asp.net core and neo4j graph database.
My application provides an account registration system, which send an activation code to user registered email and after 24 hours, if user doesn't click on the active link, the account will be deleted.
My question is : can I write a trigger in neo4j graph database to automatically runs after 24 hours after a node has been created to check whether it has been verified or not and delete it if it hasn't.
Can anyone help me please ?
Thank you :)
You can use apoc
job management:
1) Create user:
CREATE (U:User {created_at: timestamp(), activated: false})
2) Running periodic task (every hour), which takes a list of non-activated users, and checks the activation time, and remove those who do not activate account within 24 hours:
CALL apoc.periodic.repeat('name',
'MATCH (U:User {activated: false})
WHERE timestamp() - U.created_at > 24 * 60 * 60 * 1000
DETACH DELETE U',
60 * 60)
There are multiple solutions that handle this :
First one is a neo4j plugin called neo4j-expire
where you can set a time-to-live
timestamp on a node and this node will be automatically expired/deleted by the plugin at the given time :
https://github.com/graphaware/neo4j-expire
The second solution is to create a Cypher query that performs this check and register it with the job management procedures available in neo4j-apoc
https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_job_management
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With