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

Editing Events

Up Next

Deleting Events

Autoplaying in 7 seconds!


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.');

Chris Sevilleja

168 posts

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