I try it in all possible ways:
Modelo.findById(req.params.id).then(datos =>{
datos.name="value"
datos.save();
}).catch(err=>{
res.json(err);
})
Here I do it with a return
:
Modelo.findById(req.params.id).then(datos =>{
datos.name="value
return datos.save();
}).catch(err=>{
res.json(err);
})
Also with call instead of promises:
Modelo.findById(req.params.id,function(err,datos){
datos.name="value"
datos.save(function(err){
if(!err){
res.render("app/imagenes/show",{imagen:imagen})
}else{
res.render("app/imagenes/"+imagen._id+"/edit",{imagen:imagen})
}
})
})
None of the three works, I know there are the methods of findByIdAndUpdate
and findOneAndUpdate
but the problem with them is that the hooks do not work