mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-01-26 09:02:33 +00:00
18 lines
404 B
JavaScript
18 lines
404 B
JavaScript
var workout = require('../../data/models/workout');
|
|
|
|
function loadworkout(req, res, next) {
|
|
workout.findOne({title: req.params.title})
|
|
.populate('author')
|
|
.exec(function(err, workout) {
|
|
if (err) {
|
|
return next(err);
|
|
}
|
|
if (! workout) {
|
|
return res.send('Not found', 404);
|
|
}
|
|
req.workout = workout;
|
|
next();
|
|
});
|
|
}
|
|
|
|
module.exports = loadworkout; |