{
"_id": {
"$oid": ""
},
"email": "",
"password": "",
"profile": {
"picture": "",
"website": "",
"location": "",
"gender": "",
"name": ""
},
"workdetails": [
{
"company_name": "",
"job_title": "",
"role": ""
},
{
"company_name": "",
"job_title": "",
"role": ""
},
}
如何使用nodejs为mongodb中的workdetails创建工作细节的模式并存储多个文档。请指导。
答案 0 :(得分:0)
您可以将其声明为数组
workdetails: { type : Array , "default" : [] }
插入可以像
objectn.workdetails= [{
"company_name": "",
"job_title": "",
"role": ""
}, {
"company_name": "",
"job_title": "",
"role": ""
}];
yourschema.create(objectn, function (err, a, b) {
if (err) // ...
});