2
我正在使用貓鼬並試圖級聯刪除,但不幸的是我的預刪除中間件不是由於某種原因而燒製的。預刪除中間件未燒製
var presentationSchema = new Schema({
id: Number,
title: String,
pdfURL: String,
created_at: Date,
updated_at: Date,
slides: [{
type: Schema.Types.ObjectId,
ref: 'Slide'
}]
});
presentationSchema.pre('remove', function(next) {
console.log("delete slides" + this._id);
next();
});
// the schema is useless so far
// we need to create a model using it
var Presentation = mongoose.model('Presentation', presentationSchema);
// make this available to our users in our Node applications
module.exports = Presentation;
感謝,這是正是我的問題,當 – otusweb