maybe use await correctly now?

This commit is contained in:
Cassie Tarakajian 2017-12-26 22:17:53 -05:00
parent 434ee8e013
commit 362a9702f4

View file

@ -29,21 +29,18 @@ Project.count({})
.exec().then((numProjects) => { .exec().then((numProjects) => {
console.log(numProjects); console.log(numProjects);
for (let i = 0; i < numProjects; i += CHUNK) { for (let i = 0; i < numProjects; i += CHUNK) {
await Project.find({}).skip(i).limit(CHUNK).exec() let projects = await Project.find({}).skip(i).limit(CHUNK).exec();
.then((err, projects) => { projects.forEach((project, projectIndex) => {
projects.forEach((project, projectIndex) => { console.log(project.name);
console.log(project.name); project.files.forEach((file, fileIndex) => {
project.files.forEach((file, fileIndex) => { if (file.url && file.url.includes('p5.js-webeditor')) {
if (file.url && file.url.includes('p5.js-webeditor')) { file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET);
file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET); }
} let savedProject = await project.save();
project.save((err, savedProject) => { console.log(`updated file ${file.url}`);
console.log(`updated file ${file.url}`); process.exit(0);
process.exit(0); });
}); });
});
});
});
} }
}); });