Auto-update value in Postgres/TypeOrm

Viewed 24

I have a table called customers which has a column called pin. A customer can generate this pin(from app) while making an offline purchase and give that pin at the POS/Kiosk to establish identity. This pin gets generated fresh every time a customer requests for it and is stored in the DB(in the customer table under column - pin) and is set to "null" again after payment confirmation.

However, if the customer generates a pin and does not make a purchase, the pin remains in the DB. I would like to know if there is any way to update this value to null after a certain time period without having to run a cron job or something or the use of a timestamp(if I should use a timestamp please let me know how).

I am using Postgres with TypeOrm on NestJs.

Any suggestions are welcome. Thank you.

0 Answers
Related