title: MongoDB - How to remove duplicates
body: <p>I have a collection which have many duplicates due to the routines that populated it in the first place. How to dedupe these?</p>
  
  <p>e.g.</p>
  
  <pre><code>   {  "_id" : ObjectId("531a5fe448757e00244096fa"), "code" : "ap", "name" : "[Almost Perfect]", "value" : "[u'*']" }
      { "_id" : ObjectId("531a731148757e17587a6e04"), "code" : "ap", "name" : "[Almost Perfect]", "value" : "[u'*']" }
     {  "_id" : ObjectId("531a7bb848757e1f7c0ca702"), "code" : "ap", "name" : "[Almost Perfect]", "value" : "[u'*']" }
  </code></pre>
  
  <p>I want it to be just one (don't care which objectID gets picked)</p>
  
  <pre><code>   {  "_id" : ObjectId("531a5fe448757e00244096fa"), "code" : "ap", "name" : "[Almost Perfect]", "value" : "[u'*']" }
  </code></pre>