update with mongoose when saving with save () does not trigger the process

0

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

    
asked by Jesus 28.09.2018 в 09:51
source

0 answers