Created
November 10, 2014 21:38
-
-
Save ivanoats/15a2755abbb776c094fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var async = require('async'); | |
var Enrollment = require('../models/enrollment'); | |
var Student = require('../models/student'); | |
var Course = require('../models/course'); | |
module.exports = function(app) { | |
app.get('/api/studentsincourse/:courseId', function(req, res) { | |
Enrollment.find({courseId: req.params.courseId}, function(err, enrollments) { | |
var studentsList = []; | |
async.forEach (enrollments, function(enrollee, callback) { | |
console.log('Processing ', enrollee); | |
Student.findOne({_id: enrollee.studentId}, function(err, students) { | |
console.log(students); | |
studentsList.push(students); | |
}); | |
callback(); | |
}); | |
console.log(studentsList); | |
res.send('worked') | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment