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) => {
|
const deleteChecksByTeamId = async (teamId) => {
|
||||||
try {
|
try {
|
||||||
const teamMonitors = await Monitor.find({ teamId: teamId });
|
const teamMonitors = await Monitor.find({ teamId: teamId });
|
||||||
teamMonitors.forEach(async (monitor) => {
|
let totalDeletedCount = 0;
|
||||||
await Check.deleteMany({ monitorId: monitor._id });
|
|
||||||
});
|
|
||||||
|
|
||||||
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) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user