refactor(groups): small groups-creation cleanup
This commit is contained in:
@@ -147,16 +147,15 @@ api.create = function(req, res, next) {
|
||||
group.balance = 1;
|
||||
user.balance--;
|
||||
|
||||
user.save(function(err){
|
||||
if(err) return res.json(500,{err:err});
|
||||
group.save(function(err, saved){
|
||||
if (err) return res.json(500,{err:err});
|
||||
saved.populate('members', nameFields, function(err, populated){
|
||||
if (err) return res.json(500,{err:err});
|
||||
return res.json(populated);
|
||||
});
|
||||
});
|
||||
});
|
||||
async.waterfall([
|
||||
function(cb){user.save(cb)},
|
||||
function(saved,ct,cb){group.save(cb)},
|
||||
function(saved,ct,cb){saved.populate('members',nameFields,cb)}
|
||||
],function(err,saved){
|
||||
if (err) return next(err);
|
||||
res.json(saved);
|
||||
});
|
||||
|
||||
}else{
|
||||
async.waterfall([
|
||||
function(cb){
|
||||
|
||||
Reference in New Issue
Block a user