I'm trying to get a list of unique values from the 'type' field from my mongodb collection. Example documents below:
{
"_id" : ...,
"type" : "report",
"tasks" : ...
}
{
"_id" : ...,
"type" : "research",
"tasks" : ...
}
{
"_id" : ...,
"type" : "memo",
"tasks" : ...
}
{
"_id" : ...,
"type" : "memo",
"tasks" : ...
}
{
"_id" : ...,
"type" : "report",
"tasks" : ...
}
{
"_id" : ...,
"type" : "report",
"tasks" : ...
}
I'm looking for, ordered by frequency, the unique types that are in the type field of the documents, so:
["report", "memo", "research"]
What's the best way to do this? Hopefully I can do this by querying with mongo and not downloading the entire collection...