I have some documents like this:
{
"user": '1'
},
{ "user": '1'
},
{
"user": '2'
},
{
"user": '3'
}
I'd like to be able to get a set of all the different users and their respective counts, sorted in decreasing order. So my output would be something like this:
{
'1': 2,
'2': 1,
'3': 1
}
I think this can be done with a Mongo aggregate(), but I'm having a lot of trouble figuring out the right flow for this.