change return type, set monitor status to default true value
This commit is contained in:
1 parent
0a11de47d7
commit
ca7e06b8c5
1 file changed
+11
-4
@@ -197,11 +197,18 @@ const deleteChecks = async (monitorId) => {
|
||||
const deleteChecksByTeamId = async (teamId) => {
|
||||
try {
|
||||
const teamMonitors = await Monitor.find({ teamId: teamId });
|
||||
teamMonitors.forEach(async (monitor) => {
|
||||
await Check.deleteMany({ monitorId: monitor._id });
|
||||
});
|
||||
let totalDeletedCount = 0;
|
||||
|
||||
return true;
|
||||
await Promise.all(
|
||||
teamMonitors.map(async (monitor) => {
|
||||
const result = await Check.deleteMany({ monitorId: monitor._id });
|
||||
totalDeletedCount += result.deletedCount;
|
||||
monitor.status = true;
|
||||
await monitor.save();
|
||||
})
|
||||
);
|
||||
|
||||
return totalDeletedCount;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user