I have table with 5 columns
------------------------------------------------------
|_id(mongo default)| link | name| street|zip | phone |
|------------------|------|-----|-------|----|-------|
|somethin |23 |a | b |c |1 |
|something * |24 |a | b |c |1 |
|something ** |27 |a2 | b |c |1 |
------------------------------------------------------
I want to find all the disctinct rows available ignoring the link column . Is it possible to do that way in mongo ? The above table would give me two rows .. 1st and 3rd
one way I figured out was to get disctint:name,street,zip,phone to get an array
and then query back where name=>name[0],street=> street[0],zip=>zip[0],phone=>phone[0]
Any better approach?
Since the distinct command can only accept one key field, you can use group() command or Map/Reduce to achieve what you want.
An example is given in this url – http://groups.google.com/group/mongodb-user/browse_thread/thread/5f571f39ee79b75f?pli=1