Tag Archives: Empire5Design

Meteor – Distinct MongoDB Query

Meteor doesn’t support distinct in query. Say, i have a dataset as follow.

{
  "student":
  [
    { "_id": "1", "class": "1A", "name": "Peter" },
    { "_id": "2", "class": "1A", "name": "Jack" },
    { "_id": "3", "class": "1B", "name": "Mary" },
    { "_id": "4", "class": "1C", "name": "Sam" },
    { "_id": "5", "class": "1C", "name": "Ann" },
  ]
}

 

What i would like to know is how many distinct classes are there. Here is the solution suggested by Jonathan Pidgeon from Empire5Design.
Continue reading Meteor – Distinct MongoDB Query