Dodal delete movies
This commit is contained in:
parent
e75952fb52
commit
757acd9014
@ -104,16 +104,21 @@ module.exports = {
|
||||
*/
|
||||
remove: function (req, res) {
|
||||
var id = req.params.id;
|
||||
|
||||
MovieModel.findByIdAndRemove(id, function (err, movie) {
|
||||
if (err) {
|
||||
return res.status(500).json({
|
||||
message: 'Error when deleting the movie.',
|
||||
error: err
|
||||
console.log(id);
|
||||
MovieModel.findOneAndDelete({ code: id })
|
||||
.then(movie => {
|
||||
if (!movie) {
|
||||
return res.status(404).json({
|
||||
message: 'No such movie'
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(204).json();
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({
|
||||
message: 'Error when deleting the movie.',
|
||||
error: err
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@ -13,6 +13,6 @@ router.post('/', movieController.create);
|
||||
|
||||
//router.put('/:id', movieController.update);
|
||||
|
||||
//router.delete('/:id', movieController.remove);
|
||||
router.delete('/:id', movieController.remove);
|
||||
|
||||
module.exports = router;
|
Loading…
x
Reference in New Issue
Block a user