2016-11-14 19:57:10 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
2023-02-24 03:42:21 +08:00
|
|
|
export default async function clearBreakouts(breakoutId) {
|
2017-10-12 05:25:18 +08:00
|
|
|
if (breakoutId) {
|
2016-11-25 03:22:04 +08:00
|
|
|
const selector = {
|
2017-10-12 05:25:18 +08:00
|
|
|
breakoutId,
|
2016-11-25 03:22:04 +08:00
|
|
|
};
|
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-02-25 02:18:45 +08:00
|
|
|
const numberAffected = await Breakouts.removeAsync(selector);
|
2016-11-17 23:20:40 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Breakouts (${breakoutId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing Breakouts (${breakoutId})`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-02-25 02:18:45 +08:00
|
|
|
const numberAffected = await Breakouts.removeAsync({});
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Breakouts (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error('Error on clearing Breakouts (all)');
|
|
|
|
}
|
|
|
|
}
|
2016-11-14 19:57:10 +08:00
|
|
|
}
|