对于值#34; [object Object]",转换为ObjectId失败在路径" e"

时间:2014-09-23 07:56:05

标签: angularjs mongoose mongoose-populate

以下是我的架构

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”

0 个答案:

没有答案