Skip to content

Instantly share code, notes, and snippets.

@marianoqueirel
Created July 4, 2018 12:13
Show Gist options
  • Save marianoqueirel/6eddd889f5a0d3fcfed4abbfaffe540b to your computer and use it in GitHub Desktop.
Save marianoqueirel/6eddd889f5a0d3fcfed4abbfaffe540b to your computer and use it in GitHub Desktop.
Student.find(search)
.populate('sections')
.then(students => {
return students.filter(student => {
let flag = false;
student.sections.forEach(section => {
if (section.year === req.query.year) {
flag = true;
}
})
return flag;
})
})
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment