【发布时间】:2021-03-18 15:43:16
【问题描述】:
我正在制作以下猫鼬模式,并且我想确保没有对象具有相同的 autherFirstName 和 autherLastName。对象可能有一个共同点,但不能同时拥有两个
const authorShcema = new mongoose.Schema({
autherFirstName: {type: String, minLength: 2, required: true},
autherLastName: {type: String, minLength: 2, required: true},
autjorDob: {type: Date, required: true},
authorImage: {type: String},
authorBooks: [{type: mongoose.Schema.Types.ObjectId, ref: "Book"}],
});
【问题讨论】:
标签: javascript node.js mongodb mongoose mongoose-schema