title: Problem "$gte" : "?" in production on MongoDb with NodeJs
body: <p>I have a problem with an execution difference between QA and Production environment using Node + (Mongoose or TypeOrm) + MongoDb.</p>
  <p>The problem occurs when using the &quot;$gte&quot; function which works in QA environment and returns records, but in production environment it doesn't.</p>
  <p>During the analysis I was able to identify that apparently MongoDb is not able to identify the date value in production, because in the query filter it is like this <strong>&quot;$gte&quot; : &quot;?&quot;</strong></p>
  <p>The problem is that this only happens in production. And the environment in theory is equalized because we use container docker between environments and the Mongo version is equivalent too.</p>
  <p>The only detail I was able to identify is the -03:00 difference contained in the production record, but I don't believe that's it:</p>
  <p><strong>QA:</strong> createdAt: ISODate(&quot;2021-06-28T13:46:24.612Z&quot;) <br>
  <strong>PRODUCTION:</strong> createdAt: ISODate(&quot;2021-06-29T12:20:32.554-03:00&quot;)</p>
  <p>Below, the MongoDb version, the code, the Grafana log and the logs of the query executed in MongoDb in each environment:</p>
  <p>MogoDb version production: 4.2.3 <br>
  MogoDb version qa: 4.2.3</p>
  <pre class="lang-js prettyprint-override"><code>  public async getReturnFiles(user: IUserToken): Promise&lt;Orders[]&gt; {
      const filter = {
        customId: user.customId,
        createdAt: {
          $gte: moment().subtract(5, 'days').startOf('day').toDate(),
        },
        returnFile: { $ne: null },
      };
      logger.info(`OrderService::getReturnFiles::filter::`, filter);
      return this.ordersModel
        .find(filter)
        .sort({ createdAt: 'DESC' })
        .select(this.keys.join(' '))
        .exec();
    }
  </code></pre>
  <p><strong>Grafana log (production and qa is the same thing)</strong></p>
  <pre class="lang-js prettyprint-override"><code>OrderService::getReturnFiles::filter:: {&quot;select&quot;:[&quot;createdAt&quot;,&quot;_id&quot;,&quot;returnFile&quot;],&quot;order&quot;:{&quot;createdAt&quot;:&quot;DESC&quot;},&quot;where&quot;:{&quot;customId&quot;:&quot;37296592000140_FOO&quot;,&quot;orderStatus&quot;:&quot;Executed&quot;,&quot;createdAt&quot;:{&quot;$gte&quot;:&quot;2021-06-27T00:00:00.000Z&quot;}}}
  </code></pre>
  <p><strong>Query executed in QA</strong></p>
  <pre class="lang-js prettyprint-override"><code>{
      &quot;op&quot; : &quot;query&quot;,
      &quot;ns&quot; : &quot;foo.orders&quot;,
      &quot;command&quot; : {
          &quot;find&quot; : &quot;orders&quot;,
          &quot;filter&quot; : {
              &quot;customId&quot; : &quot;55029848000135_FOO&quot;,
              &quot;orderStatus&quot; : &quot;Executed&quot;,
              &quot;createdAt&quot; : {
                  &quot;$gte&quot; : ISODate(&quot;2021-06-25T00:00:00Z&quot;)
              }
      }
       }
  }
  </code></pre>
  <p><strong>Query executed in PRODUCTION</strong></p>
  <pre class="lang-js prettyprint-override"><code>{
      &quot;op&quot; : &quot;query&quot;,
      &quot;ns&quot; : &quot;foo.orders&quot;,
      &quot;command&quot; : {
          &quot;find&quot; : &quot;orders&quot;,
          &quot;filter&quot; : {
              &quot;customId&quot; : &quot;37296592000140_FOO&quot;,
              &quot;orderStatus&quot; : &quot;Executed&quot;,
              &quot;createdAt&quot; : {
                  &quot;$gte&quot; : &quot;?&quot;
              }
          }
       }
  }
  </code></pre>