title: how do i apply $match, $group and $sum in single query using mongoose/mongodb
body: <p>I am trying to find solution with my basic knowledge of MongoDB.</p>
  
  <p>I have data like below</p>
  
  <pre><code>{
   _id: 45556,
   "name": "John",
   "gender": "male",
   "lunch_preference":[
               {"outlet":"KFC", "day":"monday", "spent":300},
               {"outlet":"Mc", "day":"friday", "spent":250},
               {"outlet":"dominos", "day":"sunday", "spent":400}
    ]
  }
  
  {
   _id: ab123,
   "name": "Peter",
   "gender": "male",
   "lunch_preference":[
               {"outlet":"dominos", "day":"tuesday", "spent":150},
               { "outlet":"Mc", "day":"wednesday", "spent":350},
               {"outlet":"dominos", "day":"sunday", "spent":300}
   ]
  }
  </code></pre>
  
  <p>Here i am filtering the data using <code>$match</code> 
  My query for filtering:</p>
  
  <pre><code>db.lunch.aggregate([{"$unwind":"$lunch_preference"}, {$match: {"lunch_preference.outlet": "dominos"}},{$match: {"lunch_preference.day": "sunday"}}])
  </code></pre>
  
  <p>This query working fine!
  Now I want to calculate(sum of spendings) the spendings of above filtered data so i applied like below.</p>
  
  <pre><code>db.lunch.aggregate([{"$unwind":"$lunch_preference"}, {$match: {"lunch_preference.outlet": "dominos"}}, {$match: {"lunch_preference.day": "sunday"}}, { $group: { "_id": "$lunch_preference.outlet", totalAmount: { "$sum": "$lunch_preference.spent"}} }])
  </code></pre>
  
  <p>Result is:</p>
  
  <pre><code>{ "_id" : "dominos", "totalAmount" : 0 }
  </code></pre>
  
  <p>it is showing total amount zero, help me!</p>