猫鼬鉴别器和图式

时间:2019-05-19 07:03:12

标签: javascript mongoose

我正在使用猫鼬识别符,我想在Schema中添加方法,但是我不知道该怎么做。在哪里以及如何定义Schema?

const User = Account.discriminator(
  "User",
  new mongoose.Schema({
    firstName: {
      type: String,
      default: "First Name"
    },
    lastName: {
      type: String,
      default: "Last Name"
    },
    ShoppingCart: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "ShoppingCart"
    }
  })
);

module.exports = mongoose.model("User");

0 个答案:

没有答案