以下是我的架构
var a = new Schema({
d: {
type: Schema.ObjectId,
ref: 'Student'
},
e: {
type: Schema.ObjectId,
ref: 'Student'
},
f: {
type: [{
type: Schema.ObjectId,
ref: 'Exam'
}],
select: true
},
});
Api.js
exports.updateClassSection = function(req,res){
var _classSectionId = req.classSection._id;
ClassSection
.findOne({'_id':_classSectionId})
.populate('d e')
.exec(function(err,classSection){
console.log("ClassSection");
console.log(classSection);
classSection.e=req.body.e;
classSection.f=req.body.f;
classSection.save().then(function(data){
console.log("ClassSection saved");
},function(err){
console.log("Error");
console.log(err);
});
});
};
我填充对象'e'和'f'。但仍然,我在路径“e”处得到错误Cast to ObjectId的值“[object Object]”失败了..它也出现在“f”