refactor getMonitorById for clarity

This commit is contained in:
Alex Holliday committed 2024-11-05 12:27:13 +08:00
1 parent b5e8bdbdcd
commit 4601f95686
1 file changed
+6 -6
+6 -6
View File
@@ -314,12 +314,12 @@ const getMonitorById = async (monitorId) => {
const notifications = await Notification.find({
monitorId: monitorId,
});
const updatedMonitor = await Monitor.findByIdAndUpdate(
monitorId,
{ notifications },
{ new: true }
).populate("notifications");
return updatedMonitor;
// Update monitor with notifications and save
monitor.notifications = notifications;
await monitor.save();
return monitor;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "getMonitorById";