删除基于另一个包含项目ID的已删除文档的MongoDb文档

时间:2016-05-06 10:17:56

标签: node.js mongodb mongoose mongoose-populate mongoose-schema

我有一个mongoDb Schema

var eventSchema = new Schema({
    title :{type: String, required: true},
    description : String,
    adress : String,
    country :String,
    createdOn: {type: Date, default: Date.now},
    createEnd: {type: Date},
    state : Boolean,
    userid: {type: Schema.Types.ObjectId , ref: 'Organizer'}
});

和另一个appelOffre架构,其中包含来自预览架构的ID和

var appelOffreSchema = new Schema({
    title: {type: String, required: true},
    description : String,
    category : {type: Schema.Types.ObjectId , ref: 'Category'},
    retraitCahierCharge : String,
    createdOn: {type: Date, default: Date.now},
    createEnd: {type: Date},
    state : Boolean,
    userid: {type: Schema.Types.ObjectId , ref: 'Organizer'},
    eventid: {type: Schema.Types.ObjectId , ref: 'Event'}
});

我希望在删除第一个时自动删除第二个。有帮助吗?

0 个答案:

没有答案