Created
March 25, 2019 16:47
-
-
Save dancgray/c301d502ce5300d8e9be96e9dd56cc34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateStartIds(cb) { | |
app.contentmanager.getContentPlugin('course', function (err, coursePlugin) { | |
coursePlugin.retrieve({_id: courseId}, function(err, results) { | |
var start = { _start: results[0]._start }; | |
if(!start._start || !start._start._startIds || start._start._startIds.length == 0) return cb(); | |
var newStartIds = []; | |
start._start._startIds.forEach(function(item, index) { | |
var newStartId = _.clone(item); | |
if (metadata.idMap[item._id]) { | |
start._start._startIds.splice(index); | |
newStartId._id = metadata.idMap[item._id]; | |
start._start._startIds.push(newStartId); | |
} | |
}); | |
var search = {_id: courseId}; | |
coursePlugin.update(search, start, function(err, results) { | |
if (err) return cb(err); | |
cb() | |
}); | |
}) | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment