async destroy (req, res) { await Ad.findByIdAndDelete(req.params.id) return res.send() }
Address.findByIdAndDelete(req.query.address) .then(address => { res.status(200).json({ message: "Deleted Successfully", address }); }) .catch(err => { res.status(400).json({ message: "Couldn't delete", err }); });
User.findById(req.user.id, (err, user) => { if (user.username != "admin") { res.status(400).json({ message: "You can't delete, please contact your admin" }); } else { Product.findByIdAndDelete(req.params.id, err => { if (err) { res.status(400).json({ message: "Couldn't delete, try again" }); } else { res.status(200).json({ message: "Deleted Successfully" }); } }); } });
Category.findByIdAndDelete(req.params.id) .then(() => { return res.status(200).json({ message: `Category was deleted Succefully` }); }) .catch(error => { return res .status(400) .json({ error, message: "Couldn't delete, please try again" }); });
async destroy (req, res) { await Ad.findByIdAndDelete(req.params.id); return res.send(); }
async destroy(req, res) { await Product.findByIdAndDelete(req.params.id); return res.send(); }