Node.js Can';使用mongoose模式在数组中存储多模块对象

Node.js Can';使用mongoose模式在数组中存储多模块对象,node.js,mongodb,mongoose-schema,Node.js,Mongodb,Mongoose Schema,我有一个这样的模式 {name :string, Answers : [{ content:string, choice:[string]}] } 在我的请求中,我有一个json {"name":"fooo", "answers":[{ "content" :"hi", "choice":["1","2","3&q

我有一个这样的模式

{name :string,
 Answers : [{
content:string,
choice:[string]}]
} 
在我的请求中,我有一个json

{"name":"fooo",

"answers":[{ 

"content" :"hi",

"choice":["1","2","3"]},

{content":"hello",

 "choice ":["0","25","3"]}
           }] 
我不知道如何在mongodb中存储“answers”数组的数据 因为当我这么做的时候

 Const test =new Test({

name:req.body.name,

answers:[{

 content :req.body.answers.content,

choice:req.body.answers.choise

}
]})

这会给我一个内容错误,但当我发送一个post请求时,白色的一个应答将工作并存储在数据库中

您的请求主体具有
应答
作为数组

{
    "name":"fooo",
    "answers":[
        { "content" :"hi", "choice":["1","2","3"] },
        { "content":"hello", choice ":["0","25","3"] }
    ]
}
您必须使用索引访问数组值,如
req.body.answers[0]。content



在这里,您可以直接使用
answers:req.body.answers
,它将指向您的请求body answers数组。

看起来答案是用大写字母拼写的