title: How to get total count include models with attributes in Sequelize?
body: <p>I need to get a Product with all count ProductModel what belong. I have one-to-many relationship</p>
  <pre><code>Product.hasMany(ProductModel)
  ProductModel.belongsTo(Product)
  </code></pre>
  <pre><code>const Product = sequelize.define('product', {
    id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
    name: { type: DataTypes.STRING, unique: true, allowNull: false },
    link: { type: DataTypes.STRING, unique: true, allowNull: false },
  })
  </code></pre>
  <pre><code>const ProductModel = sequelize.define('product_model', {
    id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
    model: { type: DataTypes.STRING, allowNull: false },
    price: { type: DataTypes.INTEGER, allowNull: false },
  })
  </code></pre>
  <p>This code works, but when i add attributes in ProductModel i get the error &quot;column &quot;product_models.id&quot; must appear in the GROUP BY clause or be used in an aggregate function&quot;, and when i add to group product_models.id i get modelCount: 1 every time, that's incorrect
  INCORRECT OUTPUT</p>
  <pre><code>    {
          &quot;id&quot;: 37,
          &quot;name&quot;: &quot;Nike Air Max 270&quot;,
          &quot;modelCount&quot;: &quot;1&quot;,
          &quot;product_models&quot;: [
              {
                  &quot;model&quot;: &quot;CV7544-600&quot;
              },
              {
                  &quot;model&quot;: &quot;DO6678-001&quot;
              },
              {
                  &quot;model&quot;: &quot;AH8050-002&quot;
              },
              {
                  &quot;model&quot;: &quot;DQ4686-300&quot;
              },
              {
                  &quot;model&quot;: &quot;AH8050-005&quot;
              },
              {
                  &quot;model&quot;: &quot;DM8315-400&quot;
              },
              {
                  &quot;model&quot;: &quot;AH8050-100&quot;
              }
          ]
      },
  </code></pre>
  <pre><code>products = await Product.findAll({
  attributes: ['id', 'name', [Sequelize.fn('count', Sequelize.col('product_models.id')), 'modelCount']],
     include: [
            {
              model: ProductModel,
              attributes: [], ///but i need some attr
            },
          ],
     group: ['product.id'],
   })
  </code></pre>
  <p>Please help to solve this problem</p>