我目前正在尝试为MERN应用程序创建一个嵌套模式(我刚刚开始学习mongoose),我有一种感觉,我创建的模式没有正确完成。我想验证一下这个回答:
quiz: [
{
question: "What is 4 X 4 ? ",
answers: [
{
type: "Smart",
content: "16"
},
{
type: "Below_Average",
content: "15"
},
{
type: "Clueless",
content: "1"
}
]
},
]
//这是我所做的
const QuizSchema = new Schema({
question: {
type: String,
default: ''
},
answers: {
type: Array
},
type: {
type: String,
default: ''
},
content: {
type: String,
default: ''
}
});
正确的做法是什么?
转载请注明出处:http://www.sxboan.com/article/20230330/2165078.html