var exercise = require('../../data/models/exercise');

function loadexercise(req, res, next) {
  exercise.findOne({_id: req.params._id})
    .exec(function(err, exercise) {
      if (err) {
        return next(err);
      }
      if (! exercise) {
        return res.send('Not found', 404);
      }
      req.exercise = exercise;
      next();
    });
}

module.exports = loadexercise;