mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 02:02:19 +00:00
refactor(groups): small groups-creation cleanup
This commit is contained in:
parent
0aec4caa78
commit
a960c63f00
1 changed files with 9 additions and 10 deletions
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Reference in a new issue