Mongoose findOneAndUpdate nested documents
问题 I'm trying to update a document which contains 2 other documents. To achieve this task, I use findOneAndUpdate , but mongoose throws me a CastError ( Cast to ObjectId failed ). My models: user.js var userSchema = new Schema({ email: String, info: { type : Schema.ObjectId, required : true, ref : 'Info' } }); module.exports = mongoose.model('User', userSchema); info.js var infoSchema = new Schema({ firstname: String, lastname: String }); module.exports = mongoose.model('Info', infoSchema); My