The below is my schema
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);
});
});
};
I populate the objects 'e' and 'f'. but still , who do I get the error Cast to ObjectId failed for value "[object Object]" at path "e".. also it occurs at "f"