mirror of
https://github.com/franjsco/trackmyd-api
synced 2025-06-06 00:29:14 +02:00
add update function in controller/routes
This commit is contained in:
@ -9,6 +9,8 @@ router
|
|||||||
|
|
||||||
router
|
router
|
||||||
.route('/devices/:deviceId')
|
.route('/devices/:deviceId')
|
||||||
.get(deviceController.view);
|
.get(deviceController.view)
|
||||||
|
.put(deviceController.update)
|
||||||
|
.patch(deviceController.update);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -20,5 +20,15 @@ function view(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update(req, res) {
|
||||||
|
Device.findOneAndUpdate({ _id: req.params.deviceId }, req.body, (err) => {
|
||||||
|
if (err) {
|
||||||
|
res.status(500).send();
|
||||||
|
}
|
||||||
|
res.status(200).send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.index = index;
|
module.exports.index = index;
|
||||||
module.exports.view = view;
|
module.exports.view = view;
|
||||||
|
module.exports.update = update;
|
||||||
|
Reference in New Issue
Block a user