Create a CRUD App with Node and MongoDB

Editing Events

Editing events is going to use two of the mongoose methods that we used earlier. We'll use Event.findOne() and the .save() method.

Here's an example:

// finding a current event
Event.findOne({ slug: req.params.slug }, (err, event) => {
  // updating that event        =;
  event.description = req.body.description; => {
    if (err)
      throw err;

    // success flash message
    // redirect back to the /events
    req.flash('success', 'Successfully updated event.');

Like this article? Follow @chrisoncode on Twitter