Add notifications to monitors before returning
This commit is contained in:
1 parent
7f35a6b922
commit
b126830110
1 file changed
+7
-1
@@ -2,6 +2,7 @@ const Monitor = require("../../../models/Monitor");
|
||||
const Check = require("../../../models/Check");
|
||||
const PageSpeedCheck = require("../../../models/PageSpeedCheck");
|
||||
const { errorMessages } = require("../../../utils/messages");
|
||||
const Notification = require("../../../models/Notification");
|
||||
|
||||
/**
|
||||
* Get all monitors
|
||||
@@ -119,7 +120,12 @@ const getMonitorsByUserId = async (req, res) => {
|
||||
createdAt: sortOrder,
|
||||
})
|
||||
.limit(limit);
|
||||
return { ...monitor.toObject(), checks };
|
||||
|
||||
// Get notifications
|
||||
const notifications = await Notification.find({
|
||||
monitorId: monitor._id,
|
||||
});
|
||||
return { ...monitor.toObject(), checks, notifications };
|
||||
})
|
||||
);
|
||||
return monitorsWithChecks;
|
||||
|
||||
Reference in new issue
Block a user