Slide 28
Slide 28 text
db.isCommercialProject(pid,
function(err,
isCommercial)
if
(isCommercial)
{
var
transactionData
=
{
members:
members,
extensions:
extensions
};
_self.setProjectTransactions(db,
type,
id,
tran
if
(err)
return
cleanup(err);
end();
});
}
else
{
app.get('/index',
function(req,
res,
next)
{
User.get(req.params.userId,
function(err,
u
if(err)
next(err);
db.find({user:
user.name},
function(err
if(err)
next(err);
cursor.toArray(function(err,
items)
if(err)
next(err);
res.send(items);
});
});
});
});
}
function
end()
{
db.getProject(pid,
function(err,
project)
{
if
(err)
return
cleanup(err);
callback(null,
project);
});
}
});
});
});
});
});
});
});
});
});
});
});
};
“Christmas
tree”
code
(also
known
as
callbacks
from
hell)
looks
familiar?
Sunday, October 2, 11