2017-10-12 10:00:28 +08:00
|
|
|
import Polls from '/imports/api/polls';
|
2016-10-22 01:11:28 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2023-03-07 21:47:43 +08:00
|
|
|
export default async function clearPolls(meetingId) {
|
2016-10-22 01:11:28 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-07 21:47:43 +08:00
|
|
|
const numberAffected = await Polls.removeAsync({ meetingId });
|
2020-11-25 04:44:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Polls (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.info(`Error on clearing Polls (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-07 21:47:43 +08:00
|
|
|
const numberAffected = await Polls.removeAsync({});
|
2016-10-22 01:42:43 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Polls (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.info(`Error on clearing Polls (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|