I'm at a loss here I know the remove method is being called but it's not removing the document in the database.
mongoose.connect('mongodb://127.0.0.1/pwrcourse', (error) => {
Course.find({}, (error, courses) => {
for (let course of courses) {
let courseDir = path.join(BASE_DIR, course.title.replace(/\s+/g, '-').toLowerCase());
for (let x = 0; x < course.lectures.length; x++) {
let pad = (x > 8) ? (x + 1) : '0' + (x + 1);
let fileName = pad + '-' + course.lectures[x].title.replace(/\s+/g, '-').toLowerCase();
let filePath = path.join(courseDir, fileName);
if (!fs.existsSync(filePath + '.m4a')) {
console.log('Course ' + course.title + ' has been removed!');
course.remove((error) => {
if (error) {
console.log(error);
}
});
break;
}
}
}
process.exit(0);
});
});
via Philip Rollins
No comments:
Post a Comment