diff --git a/Server/db/mongo/MongoDB.js b/Server/db/mongo/MongoDB.js index c03e2db1a..2813a3c00 100644 --- a/Server/db/mongo/MongoDB.js +++ b/Server/db/mongo/MongoDB.js @@ -65,8 +65,6 @@ const { getAllMonitors, getMonitorById, getMonitorsByUserId, - getMonitorByIdForIncidents, - getMonitorsByUserIdForIncidents, createMonitor, deleteMonitor, deleteAllMonitors, @@ -123,6 +121,7 @@ const { const { createNotification, getNotificationsByMonitorId, + deleteNotificationsByMonitorId, } = require("./modules/notificationModule"); module.exports = { @@ -141,8 +140,6 @@ module.exports = { getAllMonitors, getMonitorById, getMonitorsByUserId, - getMonitorByIdForIncidents, - getMonitorsByUserIdForIncidents, createMonitor, deleteMonitor, deleteAllMonitors, @@ -169,4 +166,5 @@ module.exports = { deleteMaintenanceWindowByUserId, createNotification, getNotificationsByMonitorId, + deleteNotificationsByMonitorId, }; diff --git a/Server/db/mongo/modules/notificationModule.js b/Server/db/mongo/modules/notificationModule.js index 7ed2d2064..f5c8708f4 100644 --- a/Server/db/mongo/modules/notificationModule.js +++ b/Server/db/mongo/modules/notificationModule.js @@ -1,5 +1,4 @@ const Notification = require("../../../models/Notification"); -const Notification = require("../../../models/Notification"); /** * Creates a new notification. @@ -35,7 +34,17 @@ const getNotificationsByMonitorId = async (monitorId) => { } }; +const deleteNotificationsByMonitorId = async (monitorId) => { + try { + const result = await Notification.deleteMany({ monitorId }); + return result.deletedCount; + } catch (error) { + throw error; + } +}; + module.exports = { createNotification, getNotificationsByMonitorId, + deleteNotificationsByMonitorId, };