我有这个用户模型其中以博客模型作为参考,而博客具有评论集合作为参考]
const userSchema = new Schema(
{
email: {
type: String,
required: true,
index: {
unique: true
}
},
password: {
type: String,
required: true
},
name: {
type: String,
required: true
},
website: {
type: String
},
bio: {
type: String
}
},
{
timestamps: {
createdAt: "created_at",
updatedAt: "updated_at"
}
}
);
userSchema.virtual("blogs", {
ref: "blogs",
localField: "_id",
foreignField: "author"
});
我也要删除博客数据,也删除博客集合中的任何嵌套集合如何删除它?