incident cleanup
This commit is contained in:
1 parent
1683c2980e
commit
9bce91c20d
4 files changed
+29
-5
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import mongoose, { Schema, Document, Types } from "mongoose";
|
||||
import { Check, MonitorStats } from "@/db/models/index.js";
|
||||
import { Check, Incident, MonitorStats } from "@/db/models/index.js";
|
||||
|
||||
export const MonitorTypes = [
|
||||
"http",
|
||||
@@ -99,6 +99,7 @@ MonitorSchema.pre(
|
||||
const monitorId = this._id;
|
||||
await Check.deleteMany({ "metadata.monitorId": monitorId });
|
||||
await MonitorStats.deleteMany({ monitorId });
|
||||
await Incident.deleteMany({ monitorId });
|
||||
next();
|
||||
} catch (error: any) {
|
||||
next(error);
|
||||
@@ -117,6 +118,7 @@ MonitorSchema.pre(
|
||||
if (monitorIds.length > 0) {
|
||||
await Check.deleteMany({ "metadata.monitorId": { $in: monitorIds } });
|
||||
await MonitorStats.deleteMany({ monitorId: { $in: monitorIds } });
|
||||
await Incident.deleteMany({ monitorId: { $in: monitorIds } });
|
||||
}
|
||||
next();
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in new issue
Block a user