我正在使用猫鼬识别符,我想在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");