Skip to content

Instantly share code, notes, and snippets.

@blacksheep557
Last active June 23, 2021 08:58
Show Gist options
  • Select an option

  • Save blacksheep557/49bd400b944c33c362e4e24fa2a30773 to your computer and use it in GitHub Desktop.

Select an option

Save blacksheep557/49bd400b944c33c362e4e24fa2a30773 to your computer and use it in GitHub Desktop.
export const teacherAvailableSchedulesCtrl = {
async create(schedule, params) {
const teacherId = params.auth.teacherId
const existingSchedule = (await teacherAvailabilitySchedulesDao.find({query: {teacherId}}))[0];
if (existingSchedule) {
return teacherAvailabilitySchedulesDao.update(existingSchedule._id, {
...existingSchedule,
schedule: schedule.schedule
}, {});
} else {
return await teacherAvailabilitySchedulesDao.create({teacherId, schedule: schedule.schedule}, {});
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment