await Model.findByIdAndUpdate(
id,
{updatedData},
{ new: true },
)
//controllers/tourController.js
const Tour = require('./../models/tourModel');
exports.updateTour = async (req, res) => {
try {
const tour = await Tour.findByIdAndUpdate(req.params.id, req.body, {
new: true,
});
res.status(200).json({
status: 'success',
data: {
tour: 'Updated tour ',
},
});
} catch (error) {
res.status(404).json({
status: 'Error',
message: error,
});
}
};