title: MongoDb projection on array of objects, Get matched object only
body: <p>I have mongo document like this</p>
  
  <pre><code>{
      "_id": "5b14679e592baa493e0bc208",
      "productCode": "ABC",
      "corridors": [
          {
              "countryNameEn": "Sweden",
              "countryNameFr": "Suède",
              "countryCode": "SE",
              "currencyNameEn": "Swedish Krona",
              "currencyNameFr": "Couronne suédoise",
              "currencyCode": "SEK",
              "corridorLimit": "abc"
          },
          {
              "countryNameEn": "USA",
              "countryNameFr": "Suède",
              "countryCode": "US",
              "currencyNameEn": "USA",
              "currencyNameFr": "Couronne suédoise",
              "currencyCode": "USD",
              "corridorLimit": "abc"
          }
      ]
  },
  {
      "_id": "5b14679e592baa493e0bc208",
      "productCode": "XYZ",
      "corridors": [
          {
              "countryNameEn": "Sweden",
              "countryNameFr": "Suède",
              "countryCode": "SE",
              "currencyNameEn": "Swedish Krona",
              "currencyNameFr": "Couronne suédoise",
              "currencyCode": "SEK",
              "corridorLimit": "abc"
          },
          {
              "countryNameEn": "USA",
              "countryNameFr": "Suède",
              "countryCode": "US",
              "currencyNameEn": "USA",
              "currencyNameFr": "Couronne suédoise",
              "currencyCode": "USD",
              "corridorLimit": "abc"
          }
      ]
  }
  </code></pre>
  
  <p>I want to find document whose <code>productCode</code> is <code>ABC</code> and <code>currencyCode</code> is <code>USD</code> in corridors array. How can I return only the matching object from <code>corridors</code> array like only only object that has <code>USD</code> <code>currencyCode</code> should come in result and not all array.</p>
  
  <p>I tried running this query <code>{ productCode: 'ABC', corridors: { $elemMatch: { currencyCode: "USD"}}}</code>. But it gives me the whole array and not the only matched element.</p>