title: how to use group or bucket in mongodb?
body: <p>My data is looking like : </p>
  
  <p><a href="https://i.stack.imgur.com/cEXdH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cEXdH.png" alt="hospital data"></a></p>
  
  <p>how to arrange and group the data by speciality. </p>
  
  <p>I tried like this this but it is resulting diff. format.</p>
  
  <pre><code>var data = db.collection('hms').aggregate([
      { $match: { speciality: doctorSpeciality } },
      { $project: { doctor: 1, speciality: 1, meetting_hours: 1, hospital:1 } },
      {
          $group: {
              "_id": "$doctor_speciality",
              "speciality": {$push:"$speciality"},
              "doctor":{$push :"$doctorSpeciality"},
              "hospital":{$push : "$hospital_name" },
              "meetting_hours":{$push: "$meetting_hours"}
          }
      }
  ]);
  data.toArray(function(err, doc){
      console.log("result :::" ,doc);
  }); 
  </code></pre>
  
  <p>I wanted like this format :</p>
  
  <pre><code>0:[
     { doctor:Hussain,speciality:Physician,hospital:HMS,date:2018-2-1},
     { doctor:Hussain,speciality:Physician,hospital:HMS,date:2018-2-2}
   ],
  1: [{doctor:Reza,speciality:Physician,hospital:HMS,date:2018-2-1}]
  </code></pre>
  
  <p>and so on. </p>
  
  <p>I am using MongoClient driver.</p>
  
  <p>Could someone help me or give me some hints ?</p>