I have a bunch of documents in the following format:
{
_id: "5b38c85f213751038ff4d0bb",
classes: [
{
_id: "5b38c85f21375103ytg65ju7",
standard: "12",
numberOfStudents: 45
},
{
_id: "5b38c85f2137510370987hgd",
standard: "11",
numberOfStudents: 51
},
]
}
I want to:
- Search the collection of documents by the
_idand a particular class's_id. - Update the
numberOfStudentsfor that class. - Return only the class object.
So for _id: "5b38c85f213751038ff4d0bb" & classes._id: "5b38c85f21375103ytg65ju7", updating the numberOfStudents: 43 the result I'm expecting is:
{
_id: "5b38c85f21375103ytg65ju7",
standard: "12",
numberOfStudents: 43
}
I've tried a couple of things but they all return the whole document but not the way I want it to be.
numberOfStudents?