auto delete expired updates

This commit is contained in:
saml33 2021-12-23 11:43:48 +11:00
parent ed4e15e8e5
commit f05ae776b9
1 changed files with 9 additions and 0 deletions

View File

@ -280,6 +280,15 @@ const runCron = async () => {
.find({ open: true })
.toArray()
const updates: any[] = await db
.collection("updates")
.find({ expiryDate: { $lt: Date.now() } })
.toArray()
updates.forEach(async (update) => {
db.collection("updates").deleteOne({ _id: update._id })
})
alerts.forEach(async (alert) => {
handleAlert(alert, db)
})