summaryrefslogtreecommitdiff
path: root/tools/migration
diff options
context:
space:
mode:
authorotofune <otofune@gmail.com>2017-11-07 22:39:17 +0900
committerotofune <otofune@gmail.com>2017-11-07 22:39:17 +0900
commit36a95c003aa9d66ea29befbcd9ac5c10e6d76938 (patch)
tree0f991bdc823209eb4056d6efce1dbb7819629a82 /tools/migration
parentrun parallely (diff)
downloadsharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.tar.gz
sharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.tar.bz2
sharkey-36a95c003aa9d66ea29befbcd9ac5c10e6d76938.zip
fix
Diffstat (limited to 'tools/migration')
-rw-r--r--tools/migration/use-gridfs.js14
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)