Reputation: 21
Is there a way to update an existing attribute in a node to a new value after a specific time period passes ?
For example: Node 'Offer' has the below attributes
Process:
I know that there is TTL , but I don't want my node to be deleted after 7 days, rather the attribute to be updated to "No" from "Yes"
Is there any way I can achieve this in Neo4j?
Upvotes: 2
Views: 308
Reputation: 1829
You can use apoc
procedure calls for scheduling background jobs. apoc.periodic.schedule()
makes sense in your case.
CALL apoc.periodic.schedule('offerValidater',
"MATCH (n: Offer) WHERE apoc.date.currentTimestamp() - n.CREATED_ON > 604800000 SET n.IS_VALID = 'No'",
86400)
Here I assumed that offer.CREATED_ON
is in epoch milliseconds. If you are using other format timestamps you need to do a comparison accordingly. offerValidater
routine is scheduled to run with a delay of 86400 seconds (1 day).
Upvotes: 1