mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 22:51:37 +00:00
17 lines
385 B
JavaScript
17 lines
385 B
JavaScript
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; |