title: MongoDB Aggregation for every element of array field of a document
body: <p>I have 2 collections -</p>
  <p>Student collection (sample student document)</p>
  <pre><code>{
  'id': '123',
  'name': 'john',
  'age': 25,
  'fav_colors': ['red', 'black'],
  'marks_in_subjects': [
      {
       'marks': 90,
       'subject_id': 'abc'
      },
      {
       'marks': 92,
       'subject_id': 'def'
      }
   ]
  }
  </code></pre>
  <p>Subjects collection (2 sample documents)</p>
  <pre><code>{
  'id': 'abc',
  'name': 'math'
  },
  {
  'id': 'def',
  'name': 'physics'
  }
  </code></pre>
  <p>When I query for student document for id: '123', I want the resulting output as:</p>
  <pre><code>{
  'id': '123',
  'name': 'john',
  'age': 25,
  'fav_colors': ['red', 'black'],
  'marks_in_subjects': [
      {
       'marks': 90,
       'subject_id': 'abc',
       'subject_name': 'math'
      },
      {
       'marks': 92,
       'subject_id': 'def',
       'subject_name': 'physics'
      }
   ]
  }
  </code></pre>
  <p>Now, I read the MongoDB aggregation pipelines and operators document, still, I am clueless as to how to achieve this. The doubt persists because I am not even sure if this is possible with the help of mongo aggregation pipelines since JOIN happens here for every element of the array field in the student document.</p>
  <p>It would be really helpful if anyone can help here. Thanks</p>