Jake Stokes Jake Stokes - 1 month ago 9
jQuery Question

Missing } after property list, can't find it

I don't fully understand jquery yet but I am in the middle of a course to learn some.

Part of my course required me to enter:

db.grades.aggregate(
{'$group':{'_id':'$student_id', 'average':{'$avg':'$score'}}},
{'$sort':{'average':-1}},
{'$limit':1}
)


It is throwing this error:

[thread1] SyntaxError: missing } after property list @(shell)1:39


I can't see the missing }, can someone please help me?

Answer

You should use array

db.grades.aggregate([
    {'$group':{'_id':'$student_id', 'average':{'$avg':'$score'}}},
    {'$sort':{'average':-1}},
    {'$limit':1}
])
Comments