Merge branch 'feat/Video' into 'develop'
feat: category 삭제 기능 See merge request !8
Showing
1 changed file
with
13 additions
and
2 deletions
... | @@ -177,8 +177,19 @@ router.post('/products/edit/:id', loginRequired, function (req, res) { | ... | @@ -177,8 +177,19 @@ router.post('/products/edit/:id', loginRequired, function (req, res) { |
177 | }); | 177 | }); |
178 | 178 | ||
179 | router.get('/products/delete/:id', function (req, res) { | 179 | router.get('/products/delete/:id', function (req, res) { |
180 | - CategoriModel.deleteMany({ _id: req.params.id }, function (err) { | 180 | + CategoriModel.findOne({ _id: req.params.id }, function (err, products) { |
181 | - res.redirect('/categori/products'); | 181 | + CategoriModel.deleteMany({ _id: req.params.id }, function (err) { |
182 | + VideoModel.find(function (err, myVideo) { | ||
183 | + for (var i in myVideo) { | ||
184 | + if (products.title == myVideo[i].categori) { | ||
185 | + var deleteItem = myVideo[i].categori; | ||
186 | + } | ||
187 | + } | ||
188 | + VideoModel.deleteMany({ categori: deleteItem }, function (err) { | ||
189 | + res.redirect('/categori/products'); | ||
190 | + }); | ||
191 | + }); | ||
192 | + }); | ||
182 | }); | 193 | }); |
183 | }); | 194 | }); |
184 | 195 | ... | ... |
-
Please register or login to post a comment