(Go Back) Choose State To Move From
") {
return res.status(500).json({
status: 500,
message: "No data found"
});
}
if (error) {
return res.status(500).json({
status: 500,
message: "Internal server error"
});
}
return res.status(200).json({
status: 200,
message: "Successfully retrieved user's data",
data: user
});
});
},
// Update user's data
update: (req, res) => {
const { id } = req.params;
const { name, email, password, phone, address } = req.body;
const data = { name, email, password, phone, address };
User.updateOne({ _id: id }, data, (error, user) => {
if (error) {
return res.status(500).json({
status: 500,
message: "Internal server error"
});
}
return res.status(200).json({
status: 200,
message: "Successfully updated user's data",
data: user
});
});
},
// Delete user's data
delete: (req, res) => {
const { id } = req.params;
User.deleteOne({ _id: id }, (error, user) => {
if (error) {
return res.status(500).json({
status: 500,
message: "Internal server error"
});
}
return res.status(200).json({
status: 200,
message: "Successfully deleted user's data",
data: user
});
});
}
};