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

Editing Events

Up Next

Deleting Events

Autoplaying in 7 seconds!



Table of Contents

    diting 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

    176 posts

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