added controller update to router

parent f0a6ca24
......@@ -73,7 +73,11 @@ const update = (model: Model<any>) => (req: Request, res: Response) => {
model
.findByIdAndUpdate(id, data)
.then((result) => {
return res.status(200).send(result);
if (result) {
return res.status(200).send(result);
} else {
return res.json({message: 'Not found'});
}
})
.catch((error) => {
console.log(error);
......
......@@ -11,6 +11,7 @@ const router: Router = express.Router();
router.get('/', controller.getAll(model, ['category', 'location']));
router.get('/:id', controller.get(model, ['category', 'location']));
router.delete('/:id', controller.deleteDoc(model));
router.put('/:id', controller.update(model));
router.post(
'/',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment