Add delete method

This commit is contained in:
Alex Holliday committed 2024-07-30 13:25:56 -07:00
1 parent 03ee67cfca
commit 1664bc09ea
2 files changed
+12 -5

No files matched your search

+2 -4
View File
@@ -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,
};
+10 -1
View File
@@ -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,
};