mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-01-26 17:12:33 +00:00
refactored article to workout
This commit is contained in:
18
test/routes/middleware/load_workout.js
Normal file
18
test/routes/middleware/load_workout.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user