Video Course

Create a CRUD App with Node and MongoDB: Lesson 17 of 17

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

Chris Sevilleja

162 posts

Co-founder of Slapping the keyboard until something good happens.