title: How to query nested objects in mongodb with dynamic Keys?
body: <p>Here is my schema,</p>
  <pre><code>    {
    &quot;_id&quot;: {
      &quot;$oid&quot;: &quot;62dfef1a6fa3ca52622b02e4&quot;
    },
    &quot;dealer_id&quot;: 1499,
    &quot;credentials&quot;: {
      &quot;62e12c210b2d6&quot;: {
        &quot;account_id&quot;: &quot;942646&quot;,
        &quot;terminal_id&quot;: &quot;310012&quot;,
        &quot;provider&quot;: &quot;Epay&quot;,
        &quot;supplier&quot;: &quot;verizon&quot;,
        &quot;username&quot;: &quot;hello&quot;,
        &quot;password&quot;: &quot;world&quot;,
        &quot;portal_link&quot;: &quot;https://localhost&quot;,
        &quot;certificate_key&quot;: &quot;olsjhflsaknfdlaksfd&quot;,
        &quot;certificate_file&quot;: &quot;aa.txt&quot;
      }
    },
    &quot;updated_at&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1659553693372&quot;
      }
    },
    &quot;created_at&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1658842906093&quot;
      }
    }
  }
  </code></pre>
  <p>Each credentials will have dynamic uniqid, how can i query by username?
  there will be multiple credentials for each document and how can i search by any field i also need to retrive only dealer_id which is in parent.</p>
  <p>Thank you</p>