title: MongoDB Aggregations - Is it possible to get matching values instead of sum, count, avg etc
body: <p>See the document below,</p>
  
  <pre><code> [
       {
  
          "memberId": "m1",
          "positionId": "pos1",
          "projectId": "prj1"
      },
  
      {
  
          "memberId": "m1",
          "positionId": "pos2",
          "projectId": "prj1"
      },
  
      {
  
          "memberId": "m1",
          "positionId": "pos3",
          "projectId": "prj2"
      },
  
      {
  
          "memberId": "m1",
          "positionId": "pos5",
          "projectId": "prj2"
      },
  
      {
  
          "memberId": "m2",
          "positionId": "pos3",
          "projectId": "prj2"
      }
  ]
  </code></pre>
  
  <p>I need to generate an output, for a given  <em>memberId</em>, 
  group by <em>projectIds</em> and return with associate <em>positionId</em>s for that <em>projectId</em></p>
  
  <p>Say,</p>
  
  <pre><code>{
  "result" : [ 
      {
          "_id" : {
              "project" : "prj2",
              "position" : ["pos5", "pos3"]
          }
      }, 
      {
          "_id" : {
              "project" : "prj1",
              "position" : ["pos2","pos1"]
          }
      } 
  
  ]}
  </code></pre>