title: Hiding sub-array non-matching from mongodb gte seach
body: <p>So I have been able to get my <code>gte</code> query to work for mongodb. However I have noticed that the query while yes correctly prints out the document. It does not remove/hide the subarray that are not correct.</p>
  <p>For example:</p>
  <pre><code>{history:[{starttime:1593143279079},{starttime:1593236606706}}
  </code></pre>
  <p>Now I only want the subarray that gte to 1593236606706</p>
  <p>However when  I run the following query</p>
  <pre><code>{&quot;history.starttime&quot;:{$gte:1593236606706}}
  </code></pre>
  <p>I get the correct document as yes the document has a gte then 1593236606706 however I also see all the no-relevant subarray like 1593143279079.</p>
  <p>Now I understand I could do a foreach check in node or any other program. But surely there is away to remove or hide the non-relevant documents before it returns?</p>
  <p><a href="https://i.stack.imgur.com/wZfxr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wZfxr.png" alt="Mongodb return subarray" /></a></p>
  <p>Here is the sample data</p>
  <pre><code>    {
    &quot;_id&quot;: &quot;5ef2bbb25b43e19dab7cac9f&quot;,
    &quot;UUID&quot;: &quot;72296e08-2086-3b25-b66f-09fe14e7a1b9&quot;,
    &quot;ipaddress&quot;: &quot;101.118.63.108&quot;,
    &quot;history&quot;: [
      {
        &quot;HID&quot;: &quot;3892b3d0-b5c3-11ea-a984-15a58d42facb&quot;,
        &quot;station&quot;: &quot;DRN1&quot;,
        &quot;starttime&quot;: 1592966066060,
        &quot;endtime&quot;: 1592966101344
      },
      {
        &quot;HID&quot;: &quot;4ccfd300-b5c3-11ea-a984-15a58d42facb&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1592966100016,
        &quot;endtime&quot;: 1592966101480
      },
      {
        &quot;HID&quot;: &quot;4de53aa0-b5c3-11ea-a984-15a58d42facb&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1592966101833
      },
      {
        &quot;HID&quot;: &quot;c4b7af20-b607-11ea-b80a-916b111bece1&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1592995506961,
        &quot;endtime&quot;: 1592995508535
      },
      {
        &quot;HID&quot;: &quot;c5aa4c80-b607-11ea-b80a-916b111bece1&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1592995508551,
        &quot;endtime&quot;: 1592997386659
      },
      {
        &quot;HID&quot;: &quot;186f7e40-b68f-11ea-9d92-0ff1a766d952&quot;,
        &quot;station&quot;: &quot;DRN1&quot;,
        &quot;starttime&quot;: 1593053629476,
        &quot;endtime&quot;: 1593053631582
      },
      {
        &quot;HID&quot;: &quot;cb9f79a0-b759-11ea-80ed-dbf0ea8c5f4f&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593140688441,
        &quot;endtime&quot;: 1593141273000
      },
      {
        &quot;HID&quot;: &quot;e0c4d920-b75d-11ea-80ed-dbf0ea8c5f4f&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142441905
      },
      {
        &quot;HID&quot;: &quot;92b648d0-b75e-11ea-a743-2994856ad452&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142740444
      },
      {
        &quot;HID&quot;: &quot;9db86e20-b75e-11ea-a743-2994856ad452&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142758914,
        &quot;endtime&quot;: 1593142760449
      },
      {
        &quot;HID&quot;: &quot;9ed576e0-b75e-11ea-a743-2994856ad452&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142760781
      },
      {
        &quot;HID&quot;: &quot;d670b1a0-b75e-11ea-a29a-c19990a8e870&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142854073
      },
      {
        &quot;HID&quot;: &quot;d74e1950-b75e-11ea-a29a-c19990a8e870&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142855525,
        &quot;endtime&quot;: 1593142860214
      },
      {
        &quot;HID&quot;: &quot;d948b0d0-b75e-11ea-a29a-c19990a8e870&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142858845,
        &quot;endtime&quot;: 1593142860481
      },
      {
        &quot;HID&quot;: &quot;da540650-b75e-11ea-a29a-c19990a8e870&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142860597
      },
      {
        &quot;HID&quot;: &quot;e8f683e0-b75e-11ea-a56b-635bc76b120b&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593142885149
      },
      {
        &quot;HID&quot;: &quot;3bc788d0-b75f-11ea-aab1-4d8374b59f5f&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143024093
      },
      {
        &quot;HID&quot;: &quot;5b69add0-b75f-11ea-8e0e-9de052ed5763&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143077164
      },
      {
        &quot;HID&quot;: &quot;79db9030-b75f-11ea-b9e5-6780a994ba91&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143128243
      },
      {
        &quot;HID&quot;: &quot;8f4f0c80-b75f-11ea-9c42-15965300ded2&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143164231
      },
      {
        &quot;HID&quot;: &quot;b6cfcfb0-b75f-11ea-893e-33873840b421&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143230506
      },
      {
        &quot;HID&quot;: &quot;d3c37680-b75f-11ea-9e35-8b493642ae94&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143279079
      },
      {
        &quot;HID&quot;: &quot;e9722710-b75f-11ea-9962-75b52c48511f&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143315456
      },
      {
        &quot;HID&quot;: &quot;1a92c070-b760-11ea-a959-a184cc7e1bde&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143397878
      },
      {
        &quot;HID&quot;: &quot;3146d310-b760-11ea-8069-d9d0a9c80a89&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143435968
      },
      {
        &quot;HID&quot;: &quot;569b4060-b760-11ea-8fb3-57fc4edb6600&quot;,
        &quot;station&quot;: &quot;PERTHRadio&quot;,
        &quot;starttime&quot;: 1593143498598
      },
      {
        &quot;HID&quot;: &quot;6d8b0960-b795-11ea-9545-fb36a6e7214b&quot;,
        &quot;station&quot;: &quot;DRN1&quot;,
        &quot;starttime&quot;: 1593166300405,
        &quot;endtime&quot;: 1593166301643
      },
      {
        &quot;HID&quot;: &quot;1f5d3430-b839-11ea-a52e-81ad305f80cc&quot;,
        &quot;station&quot;: &quot;DRN1&quot;,
        &quot;starttime&quot;: 1593236606706,
        &quot;endtime&quot;: 1593236607927
      }
    ]
  }
  </code></pre>