title: How to get MAX(id) GROUP BY other_field with Sequalize.js?
body: <p>I've got a mysql database which stores prices for certain products which are represented by symbols. I now want to get the latest price for each symbol. In pure mysql I can run the following:</p>
  
  <pre><code>SELECT *
  FROM prices
  WHERE id IN (SELECT MAX(id) FROM prices GROUP BY symbol);
  </code></pre>
  
  <p>I now want to do the same using <a href="http://docs.sequelizejs.com" rel="nofollow noreferrer">Sequelize.js</a>. So I tried several variations of the following:</p>
  
  <pre><code>const Sequelize = require('sequelize');
  
  const sequelize = new Sequelize('mmjs', 'root', 'xxx', {host: 'localhost', dialect: 'mysql', logging: false, pool: {max: 5, min: 1, idle: 20000, acquire: 30000, handleDisconnects: true}, operatorsAliases: false,});
  
  const Price = sequelize.define('price', {
      createdAt: {type: Sequelize.DATE(6), allowNull: false},
      symbol: {type: Sequelize.STRING, allowNull: false},
      bid: {type: Sequelize.FLOAT},
      ask: {type: Sequelize.FLOAT},
  });
  
  Price.findAll({
      attributes: [Sequelize.fn('max', Sequelize.col('id'))],
      group: ["symbol"]
  }).then((maxIds) =&gt; {
      console.log(maxIds);
      console.log(maxIds.length);  // logs the correct length of 82
      return Price.findAll({
          where: {
              id: {
                  [Sequelize.Op.in]: maxIds
              }
          }
      });
  }).then(maxPrices =&gt; {
      console.log(maxPrices);
  });
  </code></pre>
  
  <p>As said in the comment the <code>maxIds.length</code> logs the correct length of 82. But after that I get an error saying <code>Unhandled rejection Error: Invalid value price</code>. Furthermore, the <code>console.log(maxIds);</code> gives me some objects which seem to be empty of the expected max id value which I'm expecting. Below is an example of one such an object.</p>
  
  <p>Does anybody know what I'm doing wrong here? Why doesn't it give me the max ids just like the query <code>SELECT MAX(id) FROM prices GROUP BY symbol</code>?</p>
  
  <p>All tips are welcome!</p>
  
  <pre><code>price {
      dataValues: {},
      _previousDataValues: {},
      _changed: {},
      _modelOptions:
       { timestamps: true,
         validate: {},
         freezeTableName: false,
         underscored: false,
         underscoredAll: false,
         paranoid: false,
         rejectOnEmpty: false,
         whereCollection: null,
         schema: null,
         schemaDelimiter: '',
         defaultScope: {},
         scopes: [],
         indexes: [],
         name: [Object],
         omitNull: false,
         sequelize: [Object],
         hooks: {},
         uniqueKeys: {} },
      _options:
       { isNewRecord: false,
         _schema: null,
         _schemaDelimiter: '',
         raw: true,
         attributes: [Array] },
      __eagerlyLoadedAssociations: [],
      isNewRecord: false },
  </code></pre>