Is there a way to combine distinct with another command to print not only the distinct attributes but also an attribute linked to the distinct one?
For example, print only 0,foo and 1,bar from the table below.
-----------------
| id | name |
| 0 | foo |
| 1 | bar |
| 1 | bar |
I am currently using
>db.foo.distinct('id')
to return ids on a db and what to use that to print the mathcing names.
You can accomplish this with MapReduce as follows: