Tweak course population script

This commit is contained in:
Scott Erickson 2016-04-28 13:47:03 -07:00
parent 72e4e6c6c8
commit 7479357869

View file

@ -26,9 +26,14 @@ for (var courseIndex in courses) {
print('constructed', JSON.stringify(coursesData, null, '\t'));
db.classrooms.update(
{}, // Set all
//{courses: {$exists: false}}, // Set all w/out values
{$set: {courses: coursesData}},
{multi: true}
);
db.classrooms.find({}, {courses:1}).forEach(function(classroom) {
print('classroom', classroom._id);
if(classroom.courses) {
print('\tskipping');
return;
}
db.classrooms.update(
{_id: classroom._id},
{$set: {courses: coursesData}}
);
});