title: MongoDB how to select only specific sub_elements for a document?
body: <p>In MongoDB I have documents like this:</p>
  
  <pre><code>{
    "_id" : ObjectId("5cc9f3c87aa1024e079a3abf"),
    "created_at" : ISODate("2019-04-01T00:00:00.000Z"),
    "demographics" : [  
      {
        "key" : "gender",
        "value" : "male"
      }, 
      {
        "key" : "birth_year",
        "value" : 1992
      }, 
      {
        "key" : "city_or_rural",
        "value" : "rural"
      }, 
      {
        "key" : "car_purchase_intention",
        "value" : "no"
      }, 
      {
        "key" : "education_level",
        "value" : "high"
      }, 
      {
        "key" : "age",
        "value" : 26
      }
    ]
  }
  </code></pre>
  
  <p>And I would like to make a query by "created_at" but for each document in the result only returning the demographics elements which key are "age" or "gender".</p>
  
  <p>I am trying combinations of <code>$unwind</code> and <code>$project</code> but I can not obtain any proper result.</p>
  
  <p>I am expecting results as this:</p>
  
  <pre><code># 1
  {
    "_id" : ObjectId("5cc9f3c87aa1024e079a3abf"),
    "created_at" : ISODate("2019-04-01T00:00:00.000Z"),
    "demographics" : [  
      {
        "key" : "gender",
        "value" : "male"
      }, 
      {
        "key" : "age",
        "value" : 26
      }
    ]
  }
  
  # 2
  {
    "_id" : ObjectId("5cc9f3c87aa1024e079axxx"),
    "created_at" : ISODate("2019-04-01T00:00:00.000Z"),
    "demographics" : [  
      {
        "key" : "gender",
        "value" : "female"
      }, 
      {
        "key" : "age",
        "value" : 56
      }
    ]
  }
  </code></pre>