Skip to content

Commit

Permalink
_delete-deleted-user-by-id
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 1, 2024
1 parent cb2441f commit 0100dc9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/tools/_delete-deleted-user-by-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 消したリモートユーザーを物理削除する、削除フラグリセット、clean-deleted-user-objsをやった後にやる、使うな
import * as mongo from 'mongodb';
import User from '../models/user';

async function main(userId: string) {
if (!userId) throw 'userId required';
const user = await User.findOne({
_id: new mongo.ObjectID(userId),
host: { $ne: null },
isDeleted: true
});

if (user == null) {
throw `user not found`;
}

console.log('user', user);

await User.remove({
_id: user._id
});
}

const args = process.argv.slice(2);

main(args[0]).then(() => {
console.log('Done');
setTimeout(() => {
process.exit(0);
}, 30 * 1000);
});

0 comments on commit 0100dc9

Please sign in to comment.