Populate group and challenge leader on challenge GET request

This commit is contained in:
Kevin Gisi
2015-04-04 07:15:01 -04:00
parent da81241ebe
commit eef3e293e2

View File

@@ -63,6 +63,8 @@ api.get = function(req, res, next) {
// 3) Limit 30 (only show the 30 users currently in the lead) // 3) Limit 30 (only show the 30 users currently in the lead)
Challenge.findById(req.params.cid) Challenge.findById(req.params.cid)
.populate('members', 'profile.name _id') .populate('members', 'profile.name _id')
.populate('group', '_id name')
.populate('leader', 'profile.name')
.exec(function(err, challenge){ .exec(function(err, challenge){
if(err) return next(err); if(err) return next(err);
if (!challenge) return res.json(404, {err: 'Challenge ' + req.params.cid + ' not found'}); if (!challenge) return res.json(404, {err: 'Challenge ' + req.params.cid + ' not found'});