title: How remove min value in mongodb for group?
body: <p>I am beginner with mongodb.</p>
  
  <p>I need to remove min price for each store.</p>
  
  <p>the document(products):</p>
  
  <p>input:</p>
  
  <pre><code>product_id|store_id|price|color|
  --------------------------------
  1         |   1    | 10  |red
  2         |   1    | 9   |blue
  3         |   1    | 12  |red
  4         |   2    | 19  |red
  5         |   2    | 20  |red
  6         |   2    | -1  |red
  7         |   6    | 30  |red
  8         |   6    | 10  |blue
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>product_id|store_id|price|color|
  --------------------------------
  2         |   1    | 9   |blue
  3         |   1    | 12  |red
  4         |   2    | 19  |red
  5         |   2    | 20  |red
  8         |   6    | 10  |blue
  </code></pre>
  
  <p>I write this code in my.js</p>
  
  <pre><code>use stores;
  var products=db.products.distinct('product_id');
  for(i=0; i&lt;products.length; i++){
     db.products.remove({product_id:i,color:'red'}).sort({price:1}).limit(1);
  }
  </code></pre>
  
  <p>But my code not works,Please write better code or show my mistake/</p>
  
  <p>Thanks</p>