diff options
| author | otofune <otofune@gmail.com> | 2017-11-07 22:39:17 +0900 |
|---|---|---|
| committer | otofune <otofune@gmail.com> | 2017-11-07 22:39:17 +0900 |
| commit | 36a95c003aa9d66ea29befbcd9ac5c10e6d76938 (patch) | |
| tree | 0f991bdc823209eb4056d6efce1dbb7819629a82 | |
| parent | run parallely (diff) | |
| download | sharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.tar.gz sharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.tar.bz2 sharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.zip | |
fix
| -rw-r--r-- | tools/migration/use-gridfs.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/migration/use-gridfs.js b/tools/migration/use-gridfs.js index 228943f49f..bb7070f553 100644 --- a/tools/migration/use-gridfs.js +++ b/tools/migration/use-gridfs.js @@ -48,16 +48,24 @@ const migrateToGridFS = async (doc) => { async function main() { const count = await DriveFile.count({}); + console.log(`there are ${count} files.`) + const dop = Number.parseInt(process.argv[2]) || 5 + const idop = ((count - (count % dop)) / dop) + 1 return zip( 1, async (time) => { - const doc = await DriveFile.find({}, { limit: dop, skip: time * dop }) + console.log(`${time} / ${idop}`) + const doc = await db.get('drive_files').find({}, { limit: dop, skip: time * dop }) return Promise.all(doc.map(migrateToGridFS)) }, - ((count - (count % dop)) / dop) + 1 - ) + idop + ).then(a => { + const rv = [] + a.forEach(e => rv.push(...e)) + return rv + }) } main().then(console.dir).catch(console.error) |