【发布时间】:2017-06-24 09:07:21
【问题描述】:
这是我的模型。这里我从服务器接收一个名为响应的对象。现在我需要用这个响应对象更新数据库。 但问题是我只能更新变量而不是像父亲这样的对象。 父亲是一个对象,现在我需要更新父亲的名字。但是如果我使用Father.Firstname 说意外的标记,它会给我错误。 请帮我解决这个问题..
var User = mongoose.model('User', userSchema);
function createStudent(response) {
console.log(response);
var list = new User({
Firstname : response.Fname,
Age : response.age,
Lastname : response.Lname,
Father.Firstname : response.fatherfname,
Father.Lastname : response.fatherlname,
Father.Occupation : response.occupation,
Father.PlaceOfWork : response.placeofwork,
Father.OfficialAddress : response.officaladd,
Father.EmailId : response.emailid,
Father.PhoneNo : response.phoneno,
Father.MobileNo : response.mobileno,
});
list.save();
}
【问题讨论】:
标签: javascript node.js mongodb reactjs mongoose