Here is my sample MongoDB collection, I need a list of all the records by ascending order of number of subjects student enrolled.
The corresponding mysql query will be
SELECT name, COUNT(subject_code) AS NUM FROM table_name ORDER BY NUM ASC
Please help me to find a MongoDb query to do the same:
{
["name"]=> string(5) "David"
["subject_code"]=> array(5) {
[0]=> int(101)
[1]=> int(111)
[2]=> int(121)
[3]=> int(123)
[4]=> int(53)
}
}