views:

69

answers:

2

How do you select distinct records in MongoDB? This is a pretty basic db functionality I believe but I can't seem to find this anywhere else.

Suppose I have a table as follows

--------------------------
| Name    | Age          |
--------------------------
|John     | 12           |
|Ben      | 14           |
|Robert   | 14           |
|Ron      | 12           |
--------------------------

I would like to run something like SELECT DISTINCT age FROM names WHERE 1;

+2  A: 

Looks like there is a SQL mapping chart that I overlooked earlier

Josh K
+1  A: 

db.names.distinct('age')

Andrey