MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Mongoose - findByIdAndUpdate - non funziona con req.body

Devi usare req.params.user_id invece req.body.user_id

exports.updateUser = function (req, res) {   
    console.log(req.body);

    User.findByIdAndUpdate(req.params.user_id,{$set:req.body},{new:true}, function(err, result){
        if(err){
            console.log(err);
        }
        console.log("RESULT: " + result);
        res.send('Done')
    });
};