feat: schedule cron script to delete notifications older than 15 days
This commit is contained in:
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user