controllers/user-controller.js
//update a user by its _id
update a user by its _id
update a user by its _id
updateUserById({ params, body }, res) {
        User.findOneAndUpdate({ _id: params.id }, body, { new: true, runValidators: true })
            .select('-__v')
            .then(userData => {
                if (!userData) {
                    res.json(404).json({ message: 'no user found with this id!' })
                    return;
                }
                res.json(userData);
            })
            .catch(err => {
                console.log(err);
                response.status(400).json(err);
            });
    }
updateUserById ( { params , body } , res ) { User . findOneAndUpdate ( { _id : params . id } , body , { new : true , runValidators : true } ) . select ( '-__v' ) . then ( userData => { if ( ! userData ) { res . json ( 404 ) . json ( { message : 'no user found with this id!' } ) return ; } res . json ( userData ) ; } ) . catch ( err => { console . log ( err ) ; response . status ( 400 ) . json ( err ) ; } ) ; }
update a user by its _id
update a user by its _id