2016-11-14 19:57:10 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2016-11-15 00:12:54 +08:00
|
|
|
import { check } from 'meteor/check';
|
2016-11-14 19:57:10 +08:00
|
|
|
|
|
|
|
export default function({ payload }) {
|
2016-11-15 00:12:54 +08:00
|
|
|
const breakoutMeetingId = payload.breakoutMeetingId;
|
|
|
|
|
|
|
|
check(breakoutMeetingId, String);
|
|
|
|
|
2016-11-14 19:57:10 +08:00
|
|
|
const selector = {
|
|
|
|
breakoutMeetingId: payload.breakoutMeetingId,
|
|
|
|
};
|
|
|
|
const modifier = payload;
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Adding breakout to collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
insertedId,
|
|
|
|
} = numChanged;
|
|
|
|
if (insertedId) {
|
|
|
|
return Logger.info(`Added breakout id=${payload.breakoutMeetingId}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Logger.info(`Upserted breakout id=${payload.breakoutMeetingId}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
Breakouts.upsert(selector, modifier, cb);
|
|
|
|
}
|