title: Use $group with find in mongodb node.js
body: <p>I want to group by <code>user_id</code> from <code>order</code> collection where there are lots of entries but I want to fetch the top 5 users that have made more orders and sum the overall price of particular user. </p>
  
  <p>For example, if I made 10 orders I want to fetch my id and sum of my all orders.
   I have used below code but its not working:</p>
  
  <pre><code>Order.find({$group : { user_id : "$user_id"}},function(error,fetchAllTopUsers){
      console.log('##################');
        console.log(fetchAllTopUsers);
      })
  </code></pre>
  
  <p>I have checked this example but they are not using find with <code>$group</code>. I am new in Node.js and MongoDB. </p>
  
  <p><a href="https://stackoverflow.com/questions/25557966/query-and-sum-all-with-mongoose">Query and sum all with mongoose</a></p>
  
  <p><strong>Sample documents</strong> </p>
  
  <pre><code>{ user_id : '57c7f4312b3c9771219bd21c', totalprice : 100 },
  { user_id : '57c7f4312b3c9771219bd21c', totalprice : 59 },
  { user_id : '57c7f4312b3c9771219bd21c', totalprice : 26 },
  { user_id : '57c7f4312b3c9771219bd21c', totalprice : 533 },
  { user_id : '57c7f4312b3c9771219bd21c', totalprice : 544 },    
  { user_id : '57efb93fdc78c816a3a15c4a', totalprice : 250 },
  { user_id : '57efb93fdc78c816a3a15c4a', totalprice : 157 },
  { user_id : '57efb93fdc78c816a3a15c4a', totalprice : 149 },
  { user_id : '57efb93fdc78c816a3a15c4a', totalprice : 104 }
  </code></pre>
  
  <p>I'm expecting an output like below:</p>
  
  <pre><code>{
      user_id : '57c7f4312b3c9771219bd21c',
      finalTotal : 1262
  },
  {   
      user_id : '57efb93fdc78c816a3a15c4a'
      finalTotal : 660
  }
  </code></pre>