title: Undo Unwind in aggregate in mongodb
body: <p>I have multiple data something like this</p>
  
  <pre><code>{
      "_id" : ObjectId("57189fcd72b6e0480ed7a0a9"),
      "venueId" : ObjectId("56ce9ead08daba400d14edc9"),
      "companyId" : ObjectId("56e7d62ecc0b8fc812b2aac5"),
      "cardTypeId" : ObjectId("56cea8acd82cd11004ee67a9"),
      "matchData" : [ 
          {
              "matchId" : ObjectId("57175c25561d87001e666d12"),
              "matchDate" : ISODate("2016-04-08T18:30:00.000Z"),
              "matchTime" : "20:00:00",
              "_id" : ObjectId("57189fcd72b6e0480ed7a0ab"),
              "active" : 3,
              "cancelled" : 0,
              "produced" : 3
          }, 
          {
              "matchId" : ObjectId("57175c25561d87001e666d13"),
              "matchDate" : ISODate("2016-04-09T18:30:00.000Z"),
              "matchTime" : "20:00:00",
              "_id" : ObjectId("57189fcd72b6e0480ed7a0aa"),
              "active" : null,
              "cancelled" : null,
              "produced" : null
          }
      ],
      "__v" : 0
  }
  </code></pre>
  
  <p>i m doing group by <code>companyId</code> and its work fine But i want to search in <code>matchData</code>  based on <code>matchtime</code> and <code>matchId</code> For that purpose i am <code>$unwind matchData</code> after unwind i using my search query like this</p>
  
  <pre><code>db.getCollection('matchWiseData').aggregate([
  {"$match":{
     "matchData.matchId":{"$in":[ObjectId("57175c25561d87001e666d12")]}
  }},
  {"$unwind":"$matchData"},
  {"$match":{
      "matchData.matchId":{"$in":[ObjectId("57175c25561d87001e666d12")]}}
  }])
  </code></pre>
  
  <p>its give me proper result but after applying unwind is there any way to undo it I m using unwind to just search inside subdocument or there is any other way to search inside subdocument. </p>