delete all

This commit is contained in:
Alex Holliday committed 2025-11-26 23:57:40 +00:00
1 parent 6c04f46e8a
commit ee04ac2b98
7 files changed
+115 -8

No files matched your search

@@ -59,6 +59,7 @@ export interface IMonitorService {
updateData: Partial<IMonitor>
) => Promise<IMonitor>;
delete: (teamId: string, monitorId: string) => Promise<boolean>;
deleteAllInOrg: (orgId: string) => Promise<boolean>;
export: (teamId: string) => Promise<Array<Record<string, unknown>>>;
import: (
orgId: string,
@@ -665,6 +666,15 @@ class MonitorService implements IMonitorService {
return true;
}
async deleteAllInOrg(orgId: string) {
const montiors = await Monitor.find({ orgId });
for (const monitor of montiors) {
await this.jobQueue.deleteJob(monitor);
}
const deleted = await Monitor.deleteMany({ orgId });
return deleted.acknowledged;
}
export = async (teamId: string) => {
return Monitor.find({ teamId })
.select("name url port type interval n secret -_id")