Mongoose更新文档数组子文档

我有这个模式包含这样的subSchemas数组:

var timesheetSchema = mongoose.model('Timesheet', new Schema({ _owner: { type: Schema.Types.ObjectId, ref: 'User' }, name: { type: String, required: true }, members: [memberSchema], slots: [slotSchema] }), 'Timesheet'); 

插槽架构(位长很抱歉)

 var slotSchema = mongoose.model('Slot', new Schema({ _email: { required: true, type: String }, description: { required: false, type: String }, date: { required: true, type: Date }, from: { required: true, type: Date }, to: { required: true, type: Date } }), 'Slot'); 

试图推入一个新的插槽slots[]但这似乎并没有工作!

 var query = Timesheet.findByIdAndUpdate( { '_id': timesheetId }, { '$push': { 'slots': newSlot }} ); query.exec(function (error) { if (error) { console.log(error); return next(error); } return res.sendStatus(200); }); 

错误

  [CastError: Cast to undefined failed for value "[object Object]" at path "slots"] message: 'Cast to undefined failed for value "[object Object]" at path "slots"', name: 'CastError', kind: undefined, 

它说插槽是未定义的,但时间表确实有slots[]在这里输入图像描述

一些检查

  console.log('Timesheet:' + timesheet); console.log('NewSlot:' + newSlot); console.log('Timesheets slots: ' + timesheet.slots); 

结果

 Timesheet:{ members: [], slots: [], __v: 0, name: '2211221', _owner: 570babdcbc431d20afeea445, _id: 570d14f90482bf5d15a895e2 } NewSlot:{ _id: 570d18beb3d3c57715b4ee75, to: Tue Apr 12 2016 16:36:09 GMT+0200 (CEST), from: Tue Apr 12 2016 16:36:09 GMT+0200 (CEST), date: Tue Apr 12 2016 16:36:09 GMT+0200 (CEST), description: 'WEINIG', _email: 'test1' } Timesheets slots: undefined 

如果有更多的信息需要我会尽快更新我的问题!

提前致谢。