cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to auto update node attributes after a specific time period

Hi All,

Is there anyway 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

  1. Offer Name (String)
  2. Offer ID (Numeric)
  3. CREATED_ON (Timestamp)
  4. IS_VALID ('Yes'/'No')

Process:

  1. When an initial "Offer" is created IS_VALID value is "Yes"
  2. After 7 days of creation IS_VALID value should be set to "No" automatically for each of the offer

I do know that there is TTL , but I don't want my node to be deleted after 7 days but rather the attribute to be updated to "No" from "Yes"

Is there any way I can achieve this in Neo4j?

3 REPLIES 3

Hmm you could perhaps run a periodic job inside or outside of the database
that matches are all the nodes that are currently due (i.e. where the createdOn property >= 7 days ago and IS_VALID is Yes

externally cron or any other scheduler
internally apoc.periodic.repeat (but have to re-issue after restarts)

Hi Michael, thanks for your response. I also found that there is apoc.periodic.schedule. However both iterate and schedule doesn't really solve my problem as each offer can be created at any time and I need to know exactly when to update the status.

For now I have created a new attribute in the node as expired_time, and I'm populating this the moment offer node is being created. And I'll only display those offer nodes when current_time < expired_time

So to confirm, there are no record level triggers available in Ne04j ?

There are triggers in apoc that are called on data changes.

They are not super efficient though.