I think this is the precise format you wanted.
The aggregation pipeline:
[
{
"$unwind": {
"path": "$scores"
}
}
{
"$match": {
"scores.type": "homework"
}
},
{
"$group": {
"_id": {
"class_id": "$class_id",
"student_id": "$student_id"
},
"scores": {
"$push": {
"type": "$scores.type",
"score": "$scores.score"
}
}
…
Top comments (0)