title: Sequelize not accepting valid moment.js object in where clause
body: <p>I have the following sequelize query:</p>
  
  <pre><code>let prms = periods.map((period, index, arr) =&gt; {
      if (arr[index + 1]) {
          return sequelize.models.Result.aggregate('value', 'avg', {
              where: {
                  createdAt: {
                      $lt: arr[index + 1],
                      $gt: period
                  },
                  type: hook.params.headers.type,
                  entityId: hook.params.headers.entity
              }
          }).catch(err =&gt; console.log('err'));
      }
  })
  </code></pre>
  
  <p>Now, the <code>createdAt</code> property on the where object is causing me this problem:</p>
  
  <blockquote>
    <p>error:  Error: Invalid value 1506211200000
         at Object.escape (C:\Users\George\Source\Repos\myProj\node_modules\sequelize\lib\sql-string.js:50:11)
         at Object.escape (C:\Users\George\Source\Repos\myProj\node_modules\sequelize\lib\dialects\abstract\query-generator.js:917:22)</p>
  </blockquote>
  
  <p>Now I don't have any idea where the <code>1506211200000</code> number is coming from, both <code>arr[index + 1]</code> and <code>period</code> are moment.js objects, and I can verify this by doing <code>console.log(arr[index + 1].isValid(), period.isValid());</code> which prints <code>true true</code>. If  remove the createdAt restriction, there is no issue. </p>
  
  <p>Any idea what is going on here?</p>
  
  <p>NB: I am using Postgres</p>