mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 15:47:48 +01:00
fix todolist removal
This commit is contained in:
@@ -22,10 +22,14 @@ UserSchema.plugin(passportLocalMongoose);
|
||||
UserSchema.plugin(uniqueValidator);
|
||||
|
||||
UserSchema.pre('remove', async function () {
|
||||
const lists = await this.model('TodoList')
|
||||
await this.model('TodoList')
|
||||
.find({ user: this._id })
|
||||
.remove()
|
||||
.exec();
|
||||
await this.model('Todo')
|
||||
.find({ user: this._id })
|
||||
.remove()
|
||||
.exec();
|
||||
await Promise.all(lists.map(list => list.remove()));
|
||||
});
|
||||
|
||||
UserSchema.methods.generateJwt = function () {
|
||||
|
||||
Reference in New Issue
Block a user