clean up,

tests,
fixes
This commit is contained in:
2018-06-01 01:06:00 +03:00
parent db46f1a2b4
commit 2f48681944
11 changed files with 277 additions and 71 deletions

View File

@@ -13,13 +13,15 @@ const TodoSchema = Schema({
});
TodoSchema.pre('save', async function () {
const user = await this.model('User').findById(this.user);
user.todos.push(this._id);
await user.save();
if (this.isNew) {
const user = await this.model('User').findById(this.user);
user.todos.push(this._id);
await user.save();
const list = await this.model('TodoList').findById(this.list);
list.todos.push(this._id);
await list.save();
const list = await this.model('TodoList').findById(this.list);
list.todos.push(this._id);
await list.save();
}
});
TodoSchema.pre('remove', async function () {