From 2d538449843ad63c2b2d15d1a2ff444b5eac3c5f Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 4 Sep 2013 13:22:22 -0400 Subject: [PATCH] add note about populate + match in chatc --- src/controllers/groups.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 822c3230f9..b846fd8a89 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -121,16 +121,17 @@ api.postChat = function(req, res, next) { } async.series([ - function(cb){ - group.save(cb) - }, + function(cb){group.save(cb)}, function(cb){ Group.findById(group._id).populate('members', partyFields).exec(cb); } ], function(err, results){ if (err) return res.json(500, {err:err}); + + // TODO This is less efficient, but see https://github.com/lefnire/habitrpg/commit/41255dc#commitcomment-4014583 var saved = results[1]; saved.members = _.filter(saved.members, function(m){return m._id != user._id}); + res.json(saved); }) }