Remove delete-invalid-users.js

This commit is contained in:
Aya Morisawa 2018-08-26 14:29:12 +09:00
parent 3e20ea5b2e
commit 800de03187
No known key found for this signature in database
GPG Key ID: 3E64865D70D579F2
1 changed files with 0 additions and 40 deletions

View File

@ -1,40 +0,0 @@
const { default: User, deleteUser } = require('../built/models/user');
const { default: zip } = require('@prezzemolo/zip')
const migrate = async (user) => {
try {
await deleteUser(user._id);
return true;
} catch (e) {
return false;
}
}
async function main() {
const count = await User.count({
uri: /#/
});
const dop = 1
const idop = ((count - (count % dop)) / dop) + 1
return zip(
1,
async (time) => {
console.log(`${time} / ${idop}`)
const doc = await User.find({
uri: /#/
}, {
limit: dop, skip: time * dop
})
return Promise.all(doc.map(migrate))
},
idop
).then(a => {
const rv = []
a.forEach(e => rv.push(...e))
return rv
})
}
main().then(console.dir).catch(console.error)