I have an an list of student which contain scores array of object, for example:
{
"_id" : ObjectId("58a6c4542d0de393d2739979"),
"student_id" : 0,
"scores" : [
{
"type" : "exam",
"score" : 76
},
{
"type" : "quiz",
"score" : 65
},
{
"type" : "homework",
"score" : 58
}
],
"class_id" : 438
}
I need to get student from collection, based on type and respective score with and condition for example
score greater than 60 in exam and
score greater than 50 in quiz and
score greater than 45 in homework
currently i'm trying the following query
db.students.find({$and: [{'scores.type': 'exam'}, {'scores.score': {$gt: 60}}]});
but its not working for single condition.
Any help greatly appreciated.