mirror of
https://github.com/franjsco/trackmyd-api
synced 2025-06-06 00:29:14 +02:00
add remove function in controller/routes
This commit is contained in:
@ -11,6 +11,7 @@ router
|
|||||||
.route('/devices/:deviceId')
|
.route('/devices/:deviceId')
|
||||||
.get(deviceController.view)
|
.get(deviceController.view)
|
||||||
.put(deviceController.update)
|
.put(deviceController.update)
|
||||||
.patch(deviceController.update);
|
.patch(deviceController.update)
|
||||||
|
.delete(deviceController.remove);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -29,6 +29,16 @@ function update(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove(req, res) {
|
||||||
|
Device.deleteOne({ _id: req.params.deviceId }, (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;
|
module.exports.update = update;
|
||||||
|
module.exports.remove = remove;
|
||||||
|
Reference in New Issue
Block a user