Create a CRUD App with Node and MongoDB

Deleting Events

Deleting events is similar to .findOne(). Instead of .findOne(), we'll use .remove(). We can delete based on an object we pass in. Whatever matches that object will get deleted:

Event.remove({ slug: req.params.slug }, (err) => {
  // set flash data
  req.flash('success', 'Event deleted!');

  // redirect back to the events page
  res.redirect('/events');
});