[#1675] fixes to populating Group.challenges, and display challenges in party

page. I'm not sure about having challenges as a subdoc anymore, i think
it will be better performance and maintenance if we just reference
Challenge.group/members and remove User.challenges & Group.challenges
This commit is contained in:
Tyler Renelle
2013-10-31 16:20:48 -07:00
parent 4afcd406f5
commit b3804c4d1f
4 changed files with 25 additions and 15 deletions

View File

@@ -156,7 +156,7 @@ api.create = function(req, res){
var challenge = new Challenge(req.body); // FIXME sanitize
challenge.save(function(err, saved){
if (err) return res.json(500, {err:err});
Group.findByIdAndUpdate(saved.group, {$addToSet:{challenges:saved._id}}) // fixme error-check, and also better to do in middleware?
Group.update({_id:saved.group}, {$addToSet:{challenges:saved._id}}) // fixme error-check, and also better to do in middleware?
res.json(saved);
});
});