hello friends, I have a document that contains students and classes (2 collections students and classes).
each student has a mainclassid and classid.
this is an example document and the result of the aggregation that I made.
this code
return 20 document from 5 document
the results shown do not match my expectations,
I hope that every student will have a different classid like the example below
[
{
"_id": ObjectId("5a934e000102030405000001"),
"classId": ObjectId("635d2f796804b95ce6a9e5d1"),
"email": "some@mail.com",
"kelas": {
"classes": {
"classCode": "VII B",
"classId": ObjectId("635d2f796804b95ce6a9e5d1"),
"className": "B"
},
"mainClass": "VII"
},
"name": "STUDENT 1",
"phone": "08712345678",
"regDate": "29/10/2022",
"tags": []
},
{
"_id": ObjectId("5a934e000102030405000002"),
"classId": ObjectId("635d2f796804b95ce6a9e5d1"),
"email": "some@mail.com",
"kelas": {
"classes": {
"classCode": "VII C",
"classId": ObjectId("635d2f836804b95ce6a9e5d2"),
"className": "C"
},
"mainClass": "VII"
},
"name": "STUDENT 2",
"phone": "08712345678",
"regDate": "29/10/2022",
"tags": []
},
{
"_id": ObjectId("5a934e000102030405000003"),
"classId": ObjectId("635d2f796804b95ce6a9e5d1"),
"email": "some@mail.com",
"kelas": {
"classes": {
"classCode": "VII D",
"classId": ObjectId("635d2f8e6804b95ce6a9e5d3"),
"className": "D"
},
"mainClass": "VII"
},
"name": "STUDENT 3",
"phone": "08712345678",
"regDate": "29/10/2022",
"tags": []
},
{
"_id": ObjectId("5a934e000102030405000004"),
"classId": ObjectId("635d2f796804b95ce6a9e5d1"),
"email": "some@mail.com",
"kelas": {
"classes": {
"classCode": "VII E",
"classId": ObjectId("635d2f966804b95ce6a9e5d4"),
"className": "E"
},
"mainClass": "VII"
},
"name": "STUDENT 4",
"phone": "08712345678",
"regDate": "29/10/2022",
"tags": []
}
]