0

以下是我的架构

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 failed for value “[object Object]” .. 它也发生在“f”

4

0 回答 0