update data by id in mongoose

try {

let users = await User.updateOne({ _id: req.params.id }).set({ email: ‘hhihhhjih@drtgt’ });

return res.status(200).json(
{
success: true,
data: users
}
);

} catch (error) {

return res.status(400).json(
{
success: false,
message: error.message
}
);
}

Leave a Comment

Your email address will not be published. Required fields are marked *