title: Grouping records in nested documents
body: <p>I have a document like this:</p>
  
  <pre><code>{
  "_id" : ObjectId("533e6ab0ef2188940b00002c"),
  "uin" : "1396599472869",
  "vm" : {
      "0" : {
          "draw" : "01s",
          "count" : "2",
          "type" : "",
          "data" : {
              "title" : "K1"
          },
          "child" : [ 
              "1407484608965"
          ]
      },
      "1407484608965" : {
          "data" : {
              "title" : "K2",
              "draw" : "1407473540857",
              "count" : "1",
              "type" : "Block"
          },
          "child" : [ 
              "1407484647012"
          ]
      },
      "1407484647012" : {
          "data" : {
              "title" : "K3",
              "draw" : "03.8878.98",
              "count" : "1",
              "type" : "SB"
          },
          "child" : [ 
              "1407484762473"
          ]
      },
      "1407484762473" : {
          "data" : {
              "type" : "SB",
              "title" : "D1",
              "draw" : "7984",
              "count" : "1"
          },
          "child" : []
      }
  }
  }
  </code></pre>
  
  <p>How to group all records with condition (type="Block")?</p>
  
  <p>I've tried:
       <em>db.ITR.aggregate({$match:{"uin":"1396599472869"}},{$project:{"vm":1}},{$group:{_id:null,r1:{$push:"$vm"}}},{$unwind:"$r1"},{$group:{_id:null,r2:{$push:"$r1"}}},{$unwind:"$r2"})</em></p>
  
  <p>But the result is still in the form of an object and not an array. With "MapReduce" I did not get.</p>