如何删除猫鼬中带有参考馆藏的馆藏?

问题描述 投票:1回答:1

我有这个用户模型其中以博客模型作为参考,而博客具有评论集合作为参考]

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"
});

我也要删除博客数据,也删除博客集合中的任何嵌套集合如何删除它?

javascript node.js mongodb express mongoose
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.