I would like to fetch the results of specified college,
Exam table has startDate
, EndDate
, noOfStudents
and collage_id
.
Students table has examId
& subject
result table has studentId
, score
and grade
.
I have tried this below query it returns null for students and none for the exam also it has been returning all data which is present in result DB, I need only belongs to a specified college so any suggestion here, please
results.find({
include: [{
model: models.students,
include: [{
model: models.exam,
as: 'exam',
where:{collage_id:id}
}],
as: 'students'
}]
});
Output:{
"id": 1,
"student_id":2,
"score": 88,
"grade" : B,
"created_at": "2018-11-14T13:38:25.377Z",
"updated_at": "2018-11-14T13:38:25.377Z",
"students": null
}
Expected Output:{
"id": 1,
"student_id":2,
"score": 88,
"grade" : B,
"created_at": "2018-11-14T13:38:25.377Z",
"updated_at": "2018-11-14T13:38:25.377Z",
"students": {
"examId": 2
"subject":
},exam:{
"startDate":Date,
"EndDate":date,
"noOfStudents" : 100
"collage_id": 1
}
}