feat: schedule cron script to delete notifications older than 15 days

This commit is contained in:
2025-09-10 13:35:21 +05:30
parent b0863d1586
commit fc7e230fbb
2 changed files with 3 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ const notifModel = mongoose.model(
await mongoose.connect(process.env.DB_URI);
const fifthDay = new Date(Date.now() - 3600 * 24 * 5 * 1000);
const fifthDay = new Date(Date.now() - 3600 * 24 * 15 * 1000);
const result = await notifModel.deleteMany({ createdAt: { $lt: fifthDay } });
console.log(`Deleted ${result.deletedCount} notifications`);