title: How to count a group by query in NodeJS Sequelize
body: <p>In Rails I can perform a simple ORM query for the number of Likes a model has:</p>
  
  <pre><code>    @records = Model
          .select( 'model.*' )
          .select( 'count(likes.*) as likes_count' )
          .joins( 'LEFT JOIN likes ON model.id = likes.model_id' )
          .group( 'model.id' )
  </code></pre>
  
  <p>This generates the query:</p>
  
  <pre><code>SELECT  models.*, count(likes.*) as likes_count
  FROM "models" JOIN likes ON models.id = likes.model_id
  GROUP BY models.id
  </code></pre>
  
  <p>In Node Sequelize, any attempt at doing something similar fails:</p>
  
  <pre><code>return Model.findAll({
      group: [ '"Model".id' ],
      attributes: ['id', [Sequelize.fn('count', Sequelize.col('"Likes".id')), 'likes_count']],
      include: [{ attributes: [], model: Like }],
  });
  </code></pre>
  
  <p>This generates the query:</p>
  
  <pre><code>SELECT
      Model.id,
      count(Likes.id) AS likes_count,
      Likes.id AS Likes.id           # Bad!
  FROM Models AS Model
  LEFT OUTER JOIN Likes
      AS Likes
      ON Model.id = Likes.model_id
  GROUP BY Model.id;
  </code></pre>
  
  <p>Which generates the error:</p>
  
  <pre><code>column "Likes.id" must appear in the GROUP BY clause or be used in an aggregate function
  </code></pre>
  
  <p>It's erroneously selecting likes.id, and I have no idea why, nor how to get rid of it.</p>