Reputation: 2553
I am trying to do a group by on a MongoDB collection (my version is 2.2.2)
db.stream.aggregate({$group: { MyId:"A1"}})
But I get the following error:
19 11:56:20 TypeError: db.stream.aggregate is not a function (shell):1
Many Thanks,
Upvotes: 9
Views: 4597
Reputation: 42352
You must be using 2.2.+ version of the shell to be able to use the aggregate
helper.
You can check the shell version with version()
command at the shell prompt.
In addition, your aggregation syntax is incorrect - the $group
operator must set a field called _id
(you have MyId
) which is what tells it which field you are aggregating by.
Upvotes: 11