【发布时间】:2018-01-16 16:48:35
【问题描述】:
我的架构层次结构是......
List -> Items -> (attachements,comments,labels)
Que:所以如果我想删除一个列表,所有引用的(分层)元素都应该删除。这里(attachments,cmets,labels)引用了Item 和 Item 引用到 List。所以请给我一些建议。 架构:
List:{
list_title: {type: String, required: true},
created_at: Date,
updated_at: Date
}
Item:{
item_title: {type: String, required: true},
discription:{type: String},
label : {type:Array ,label_id : String },
created_at: Date,
updated_at: Date,
_list: {type: Schema.Types.ObjectId, ref:'List'}
}
Comment:{
comment:{type:String},
created_at: Date,
updated_at: Date,
entity_id : {type: Schema.Types.ObjectId, ref:''},
model : {type : String ,enum : ['Item','File'] }
}
Attachment:{
title : [{type : String}],
// files: [String],
path : [String],
make_cover : {type : Boolean },
_item: {type: Schema.Types.ObjectId, ref:'Item'}
}
提前致谢
【问题讨论】: