complementary deletions on user delete

This commit is contained in:
MuhammadKhalilzadeh committed 2024-06-28 20:13:07 +03:30
1 parent 318b62cd3b
commit e11ae4d460
3 files changed
+34 -2

No files matched your search

+16
View File
@@ -303,6 +303,21 @@ const deleteAllMonitors = async (req, res) => {
}
};
/**
* Delete all monitors associated with a user ID
* @async
* @param {string} userId - The ID of the user whose monitors are to be deleted.
* @returns {Promise} A promise that resolves when the operation is complete.
*/
const deleteMonitorsByUserId = async (userId) => {
try {
const result = await Monitor.deleteMany({ userId: userId });
return result;
} catch (error) {
throw error;
}
};
/**
* Edit a monitor by ID
* @async
@@ -539,4 +554,5 @@ module.exports = {
editAlert,
deleteAlert,
deleteAlertByMonitorId,
deleteMonitorsByUserId
};