UNPKG

@ideal-photography/shared

Version:

Shared MongoDB and utility logic for Ideal Photography PWAs: users, products, services, bookings, orders/cart, galleries, reviews, notifications, campaigns, settings, audit logs, minimart items/orders, and push notification subscriptions.

22 lines (19 loc) 654 B
import { models } from '../../mongoDB/index.js'; /** * Remove low-priority notifications older than 90 days */ export async function cleanupOldNotifications() { const cutoff = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000); const { deletedCount } = await models.Notification.deleteMany({ priority: 'low', createdAt: { $lt: cutoff } }); return deletedCount; } if (import.meta.url === `file://${process.argv[1]}`) { (async () => { const count = await cleanupOldNotifications(); console.log(`Deleted ${count} old low-priority notifications`); process.exit(); })(); }