feat: clear expired notification date
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s

This commit is contained in:
Methapon2001 2025-03-05 17:22:38 +07:00
parent 3803c3378a
commit c7fae98516

View file

@ -1,3 +1,4 @@
import dayjs from "dayjs";
import { CronJob } from "cron";
import prisma from "../db";
@ -25,6 +26,18 @@ const jobs = [
.catch((e) => console.error("[ERR]: Update expired quotation status, FAILED.", e));
},
}),
CronJob.from({
cronTime: "0 0 0 * * *",
runOnInit: true,
onTick: async () => {
await prisma.notification
.deleteMany({
where: { createdAt: { lte: dayjs().subtract(1, "month").toDate() } },
})
.then(() => console.log("[INFO]: Delete expired notification, OK."))
.catch((e) => console.error("[ERR]: Update expired quotation status, FAILED.", e));
},
}),
];
export function initSchedule() {