So I have this table in my database called Item and it has a condition/status field and an expiry_date field. I am using expressjs prisma on the backend, and react for the frontend. The table looks something like this:
model Item{
condition (expired,good,bad)
expiry_date (datetime)
}
What I want to do is to automatically change the status of the item if the expiry_date is greater than the date today. It's similar to a bidding/live auction system where the item automatically closes after its due time. What I'm thinking is to run a function every 24 hrs to check all items in the database and change its status accordingly. Am I approaching this problem correctly or is there a better way to implement it?
CodePudding user response:
I don’t really know how Prisma.js
works, but maybe that a micro-service is a good way. Try running it once a day.
CodePudding user response:
You can use prisma middleware (https://www.prisma.io/docs/concepts/components/prisma-client/middleware).