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({ const notifications = await Notification.find({
monitorId: monitorId, monitorId: monitorId,
}); });
const updatedMonitor = await Monitor.findByIdAndUpdate(
monitorId, // Update monitor with notifications and save
{ notifications }, monitor.notifications = notifications;
{ new: true } await monitor.save();
).populate("notifications");
return updatedMonitor; return monitor;
} catch (error) { } catch (error) {
error.service = SERVICE_NAME; error.service = SERVICE_NAME;
error.method = "getMonitorById"; error.method = "getMonitorById";