我想使用节点js在mysql中插入对象数组 我知道插入单个数据编辑删除和所有这些功能,但不知道如何做到这一点。
这是我用来发布请求的json
我想要实现的是我想在mysql表中插入问题数组。
{
"somename":"name",
"creadtedby":"admin",
"questions":[
{
"q1":"This is question one",
"created_date":"",
"created_by":"admin",
"updated_date":"sd",
"answer":[
{
"a1":"answer one",
"weight":"10"
},
{
"a2":"answer two",
"weight":"20"
}
]
},
{
"q2":"This is question two",
"answer":[
{
"a1":"answer two",
"weight":"10"
}
]
},
{
"q3":"This is question three",
"answer":[
{
"a1":"answer three",
"weight":"10"
}
]
},
{
"q4":"This is question four",
"answer":[
{
"a1":"answer one",
"weight":"10"
}
]
}
]
}
答案 0 :(得分:0)
如果您想要无缝地完成这些工作,您可能需要查看ORM for Node.js并从上述数据模型和问题模型中定义1-many关系