title: mongodb find the document by id and then group the result based on name field
body: <p>I have a collection with multiple documents like </p>
  
  <pre><code>{
      "_id" : ObjectId("5a64d076bfd103df081967ae"),
      "status" : "",
      "Number" : 53,
      "values" : [ 
          {
              "date" : "2015-05-18",
              "value" : 12.41
          },
          {
              "date" : "2015-05-19",
              "value" : 12.45
          },
  
      ],
      "Name" : "ABC Banking",
      "scheme":"ABC1",
      "createdDate" : "21-01-2018"
  }
  
  {
      "_id" : ObjectId("5a64d076bfd103df081967ae"),
      "status" : "",
      "Number" : 53,
      "values" : [ 
          {
              "date" : "2015-05-18",
              "value" : 13.41
          },
          {
              "date" : "2015-05-19",
              "value" : 13.45
          },
  
      ],
      "Name" : "ABC Banking",
      "scheme":"ABC2",
      "createdDate" : "21-01-2018"
  }
  </code></pre>
  
  <p>I am Querying collection based on Number field like</p>
  
  <pre><code>db.getCollection('mfhistories').find({'Number':53})
  </code></pre>
  
  <p>to get all the documents with this Number.</p>
  
  <p>Now I want to group all the collection with Name 'ABC Banking' into an array. so that I will get result based on Name.</p>
  
  <p>so the result should be like</p>
  
  <pre><code>{        
     "Name":"ABC Banking",
     [
       {
          "_id" : ObjectId("5a64d076bfd103df081967ae"),
          "status" : "",
          "Number" : 53,
          "values" : [ 
              {
                  "date" : "2015-05-18",
                  "value" : 13.41
              },
             {
                 "date" : "2015-05-19",
                 "value" : 13.45
             }, 
          ],
              "scheme":"ABC1",
              "createdDate" : "21-01-2018"
         },
         {
              "_id" : ObjectId("5a64d076bfd103df081967ae"),
              "status" : "",
              "Number" : 53,
              "values" : [ 
              {
                 "date" : "2015-05-18",
                 "value" : 13.41
              },
              {
                 "date" : "2015-05-19",
                 "value" : 13.45
              }
             ], 
            "scheme":"ABC2",
             "createdDate" : "21-01-2018"
           }
      ]
  }
  </code></pre>
  
  <p>Please help..</p>
  
  <p>Thanks,
  J</p>