Here is a list of lesson start times for the instructor named Johnny Appleseed:
{
_id: 'ka83nala9cya9epsj',
fullName: Johnny Appleseed,
schedule: {
'11/05/2016': '12:30',
'11/15/2016': '2:30',
'11/16/2016': '1:30',
'12/07/2016': '9:30',
'12/18/2016': '10:30',
'12/23/2016': '8:30',
}
...
}
I have been attempting to use mongo.update()
but haven't found the correct combination. Below is an example that I thought would work, but it's not quite there yet.
function removeStartTime(_instrName, _lessonDate) {
const _scheduleKey = `schedule.${_lessonDate}`;
return Instructors.update({ fullName: _instrName }, { $unset: { _scheduleKey: 1 } });
}
The Objective:
We need to unschedule (remove) Johnny Appleseed from his lesson scheduled on 12/18/2016. The updated document should appear as follows:
{
_id: 'ka83nala9cya9epsj',
fullName: Johnny Appleseed,
schedule: {
'11/05/2016': '12:30',
'11/15/2016': '2:30',
'11/16/2016': '1:30',
'12/07/2016': '9:30',
'12/23/2016': '8:30',
}
...
}
Your assistance in achieving this is greatly appreciated. Thank you!