我有一个问题,MongoosefindByIdAndUpdate
没有在回调中返回正确的模型。
我想TIMELINE.Description
从用户文档更新属性:
var refereeSchema = mongoose.Schema({
first_name: String,
last_name: String,
email: String,
phone: Number,
age: Number,
role: String,
note: Number,
favorite_teams: String,
hometown: String,
picture: String,
timeline:
{
id_Game1: String,
date_game: Date,
description: String
}
}) ;
// new timeline
router.put('/:id', function(req,res,next){
models.users.findByIdAndUpdate(req.params.id,{$set: {description : req.body.description}}, {new:true} , function(err,user){
if(err){
res.json({error :err}) ;
} else{
res.send(user) ;
}
});
});