userSchema = new Schema({email: String})
userSchema.post('remove', function() {
TodoList = require('todo_list');
TodoList.remove({user: this._id} )
})
mongoose.model("User", userSchema)
todoSchema = new Schema({user: {type:ObjectId, ref:"User"}})
todoSchema.post('remove', function() {
TodoItem = require('todo_item');
TodoItem.remove({list: this._id} )
});
mongoose.model("
ToDoList", todoSchema)
todoItemSchema = new Schema({list: {type:ObjectId, ref:"ToDoList"}})
todoItemSchema.post('remove', function() {
console.log('DELETED') // <<---- this should be triggered when the user is deleted
});
mongoose.model("ToDoItem", todoItemSchema)