From 362a9702f4b7701d20f96ea03c4ecd1a3dbae567 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 26 Dec 2017 22:17:53 -0500 Subject: [PATCH] maybe use await correctly now? --- server/migrations/moveBucket.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/server/migrations/moveBucket.js b/server/migrations/moveBucket.js index b1bc9b1d..165b0a1e 100644 --- a/server/migrations/moveBucket.js +++ b/server/migrations/moveBucket.js @@ -29,21 +29,18 @@ Project.count({}) .exec().then((numProjects) => { console.log(numProjects); for (let i = 0; i < numProjects; i += CHUNK) { - await Project.find({}).skip(i).limit(CHUNK).exec() - .then((err, projects) => { - projects.forEach((project, projectIndex) => { - console.log(project.name); - project.files.forEach((file, fileIndex) => { - if (file.url && file.url.includes('p5.js-webeditor')) { - file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET); - } - project.save((err, savedProject) => { - console.log(`updated file ${file.url}`); - process.exit(0); - }); - }); - }); - }); + let projects = await Project.find({}).skip(i).limit(CHUNK).exec(); + projects.forEach((project, projectIndex) => { + console.log(project.name); + project.files.forEach((file, fileIndex) => { + if (file.url && file.url.includes('p5.js-webeditor')) { + file.url = file.url.replace('p5.js-webeditor', process.env.S3_BUCKET); + } + let savedProject = await project.save(); + console.log(`updated file ${file.url}`); + process.exit(0); + }); + }); } });