2016-11-29 03:48:02 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
|
|
|
export default function addBreakout(payload) {
|
|
|
|
const {
|
|
|
|
breakoutMeetingId,
|
|
|
|
parentMeetingId,
|
|
|
|
name,
|
|
|
|
} = payload;
|
|
|
|
|
|
|
|
check(breakoutMeetingId, String);
|
|
|
|
check(parentMeetingId, String);
|
|
|
|
check(name, String);
|
|
|
|
|
2016-11-29 23:49:08 +08:00
|
|
|
const selector = { breakoutMeetingId };
|
2016-11-29 03:48:02 +08:00
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
breakoutMeetingId,
|
|
|
|
parentMeetingId,
|
|
|
|
name,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Adding breakout to collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
insertedId,
|
|
|
|
} = numChanged;
|
|
|
|
if (insertedId) {
|
2016-11-29 23:49:08 +08:00
|
|
|
return Logger.info(`Added breakout id=${breakoutMeetingId}`);
|
2016-11-29 03:48:02 +08:00
|
|
|
}
|
|
|
|
|
2016-11-29 23:49:08 +08:00
|
|
|
return Logger.info(`Upserted breakout id=${breakoutMeetingId}`);
|
2016-11-29 03:48:02 +08:00
|
|
|
};
|
|
|
|
|
2016-11-30 00:52:15 +08:00
|
|
|
return Breakouts.upsert(selector, modifier, cb);
|
2016-11-29 03:48:02 +08:00
|
|
|
};
|