Mongoose validieren Array von Referenzen erforderlich
const questionSchema = new mongoose.Schema({
question: {
type: String,
required: [true, 'Question Required'],
trim: true
},
options: {
type: [{
optionNo: Number,
optionValue:{
type: String,
required: [true,'Option required'],
trim: true
}
}],
validate: [(val) -> val.length > 1, 'Must have minimum two options']
}
});
Gifted Gazelle