add update function in controller/routes

This commit is contained in:
Francesco Esposito 2019-02-20 08:29:32 +01:00
parent 673857ee52
commit 4190bb2736
2 changed files with 13 additions and 1 deletions

View File

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

View File

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