title: Group by values and conditions
body: <p>Very new to mongo and having a little trouble getting my head around this problem. I have collection looking like this</p>
  
  <pre><code>{ "_id" : "PN89dNYYkBBmab3uH", "card_id" : 1, "vote" : 1, "time" : 1437700845154 }
  { "_id" : "Ldz7N5syeW2SXtQzP", "card_id" : 1, "vote" : 1, "time" : 1437700846035 }
  { "_id" : "v3XWHHvFSHwYxxk6H", "card_id" : 1, "vote" : 2, "time" : 1437700849817 }
  { "_id" : "eehcDaCyTdz6Yd2a9", "card_id" : 2, "vote" : 1, "time" : 1437700850666 }
  { "_id" : "efhcDaCyTdz6Yd2b9", "card_id" : 2, "vote" : 1, "time" : 1437700850666 }
  { "_id" : "efhcDaCyTdz7Yd2b9", "card_id" : 3, "vote" : 1, "time" : 1437700850666 }
  { "_id" : "w3XWgHvFSHwYxxk6H", "card_id" : 1, "vote" : 1, "time" : 1437700849817 }
  </code></pre>
  
  <p>I need to write a query that will group cards basically by votes (1 is like; 2 is dislike). So I need to get the total number of likes minus dislikes for each card and be able to rank them.</p>
  
  <p>Result would be like:</p>
  
  <p>card_id 1: 3 likes - 1 dislike = <strong>2</strong> </p>
  
  <p>card_id 3: 1 like - 0 dislikes = <strong>1</strong></p>
  
  <p>card_id 2: 2 likes - 0 dislikes = <strong>0</strong></p>
  
  <p>Any idea how to get the count of all the cards' 1 votes minus 2 votes and then order the results?</p>