add remove function in controller/routes

This commit is contained in:
Francesco Esposito 2019-02-20 08:54:48 +01:00
parent 4190bb2736
commit 88d8f40ee3
2 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,7 @@ router
.route('/devices/:deviceId')
.get(deviceController.view)
.put(deviceController.update)
.patch(deviceController.update);
.patch(deviceController.update)
.delete(deviceController.remove);
module.exports = router;

View File

@ -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.view = view;
module.exports.update = update;
module.exports.remove = remove;