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:

Table of Contents

    Event.remove({ slug: req.params.slug }, (err) => {
      // set flash data
      req.flash('success', 'Event deleted!');
    
      // redirect back to the events page
      res.redirect('/events');
    });

    Chris Sevilleja

    176 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.