kminny
kminny

Reputation: 239

Change data at specific condition in sequelize

I am using PostgreSQL with sequelize on Javascript project. It is about managing project schedule and I want to update my data on specific condition. For example

  1. There is one Project with 'due_date' and 'current_status'.
  2. If I set 'due_date' then 'current_status' become 'ongoing'.
  3. When current date passes 'due_date', then 'current_status' should become 'delayed'.

I want to make step 3 automatically, but I have no idea where to handle. Currently I am looking for hooks but I can not find any hooks that can satisfy it. Is there any solution for this?

Upvotes: 0

Views: 149

Answers (1)

Jonathan Jacobson
Jonathan Jacobson

Reputation: 1518

You will need to schedule a job to actively look for rows that need updating.

The job can be fired by some external scheduler (e.g. cron) or by the pg_cron extension if you're able to install it.

Upvotes: 1

Related Questions