function getGrade6Applicants(req, res, next) {
connection.query('SELECT COUNT(*) AS grade_6 FROM applications WHERE grade="Grade 6" ', function (err, rows, fields) {
if (err) {
return next(err);
};
req._applications = rows;
return next();
});}
function getGrade7Applicants(req, res, next) {
connection.query('SELECT COUNT(*) AS grade_7 FROM applications WHERE grade="Grade 7" ', function (err, rows, fields) {
if (err) {
return next(err);
};
req._applications = rows;
return next();
});}/* GET dashboard page */
router.get('/dashboard', getGrade6Applicants, function (req, res, next) {
res.render('admission/dashboard', {
'applications': req._applications
});
})This gives me the number of applications in grade6 in my applications table in mysql database.
I use this in my dashboard.handlebars page as {{grade_6}} using appropriate {{#if}} and {{#each}} built in helpers.
The problem is whenever I wanted to add second function to display number of applications in grade 7, what I have is only grade 7 applications. Grade 6 is not shown. Here is the GET request that I use for multiple values:
/* GET dashboard page */
router.get('/dashboard', getGrade6Applicants, getGrade7Applicants, function (req, res, next) {
res.render('admission/dashboard', {
'applications': req._applications
});
}) req._applications = rows; req.data = { grade6Rows: rows;};
req.data = req.data || {}; req.data['grade6Rows'] = rows;To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/75ac96b4-05d4-4948-b2ec-699a86001c8b%40googlegroups.com.--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAASE%3DRhT-UF8Ty63BOo-TLgZj-E9R7MfKguBPYsPxLoCjunH%2BQ%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/75ac96b4-05d4-4948-b2ec-699a86001c8b%40googlegroups.com.
--Fatih KaratayDove Science Academy Tulsa
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.