refactor getMonitorById for clarity
This commit is contained in:
1 parent
b5e8bdbdcd
commit
4601f95686
1 file changed
+6
-6
@@ -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";
|
||||||
|
|||||||
Reference in new issue
Block a user