title: Get instances where count of relationship is zero with Sequelize
body: <p>Below is the syntax to count the relationship on a model via Sequelize</p>
  <pre><code>    const files = await db.File.findAll({
        attributes: {
          include: [
            [Sequelize.fn('COUNT', 'Tags.id'), 'tagCount']
          ]
        },
        include: [
          {
            model: db.Tag,
            as: 'tags',
            attributes: [],
            duplicate: false
          }
        ],
        group: 'File.id',
        order: [
          [Sequelize.literal('`tagCount`'), 'DESC']
        ]
      })
  </code></pre>
  <p>What do I require to make this code return only Files that has zero tags associated to them?</p>
  <h1>Edit</h1>
  <p>As per answer provided by @Soham, it does achieve the intended result but cannot be paginated. Generated query is:</p>
  <pre><code>SELECT `File`.`id`,
  `File`.`originalId`,
  `File`.`signature`,
  `File`.`referrer_url`,
  `File`.`preview_url`,
  `File`.`preview_extension`,
  `File`.`original_url`,
  `File`.`original_extension`,
  `File`.`provider`,
  `File`.`previewedAt`,
  `File`.`viewedAt`,
  `File`.`blacklistedAt`,
  `File`.`queuedAt`,
  `File`.`startedAt`,
  `File`.`downloadedAt`,
  `File`.`createdAt`,
  `File`.`updatedAt`,
  COUNT(`tags`.`id`) AS `tagCount`,
  `tags-&gt;FileTags`.`createdAt` AS `tags.FileTags.createdAt`,
  `tags-&gt;FileTags`.`updatedAt` AS `tags.FileTags.updatedAt`,
  `tags-&gt;FileTags`.`fileId` AS `tags.FileTags.fileId`,
  `tags-&gt;FileTags`.`tagId` AS `tags.FileTags.tagId` 
  FROM `Files` AS `File` 
  LEFT OUTER JOIN `FileTags` AS `tags-&gt;FileTags` 
  ON `File`.`id` = `tags-&gt;FileTags`.`fileId` 
  LEFT OUTER JOIN `Tags` AS `tags` 
  ON `tags`.`id` = `tags-&gt;FileTags`.`tagId` 
  GROUP BY `File`.`id` 
  HAVING `tagCount` = 0 
  ORDER BY `tagCount` DESC;
  </code></pre>
  <p>When I add offset and limit to the query as per below</p>
  <pre><code>    return super.findAll({
        offset: 0,
        limit: 24,
        attributes: {
          include: [
            [Sequelize.literal('COUNT(`tags`.`id`)'), 'tagCount']
          ]
        },
        include: [
          {
            model: db.Tag,
            as: 'tags',
            attributes: [],
            duplicate: false
          }
        ],
        group: 'File.id',
        order: [
          [Sequelize.literal('`tagCount`'), 'DESC']
        ],
        having: { tagCount: 0 }
      })
  </code></pre>
  <p>and this outputs the following</p>
  <pre><code>SELECT `File`.*,
   `tags-&gt;FileTags`.`createdAt` AS `tags.FileTags.createdAt`,
   `tags-&gt;FileTags`.`updatedAt` AS `tags.FileTags.updatedAt`,
   `tags-&gt;FileTags`.`fileId` AS `tags.FileTags.fileId`,
   `tags-&gt;FileTags`.`tagId` AS `tags.FileTags.tagId` 
   FROM (SELECT `File`.`id`,
   `File`.`originalId`,
   `File`.`signature`,
   `File`.`referrer_url`,
   `File`.`preview_url`,
   `File`.`preview_extension`,
   `File`.`original_url`,
   `File`.`original_extension`,
   `File`.`provider`,
   `File`.`previewedAt`,
   `File`.`viewedAt`,
   `File`.`blacklistedAt`,
   `File`.`queuedAt`,
   `File`.`startedAt`,
   `File`.`downloadedAt`,
   `File`.`createdAt`,
   `File`.`updatedAt`,
   COUNT(`tags`.`id`) AS `tagCount` 
   FROM `Files` AS `File` 
   GROUP BY `File`.`id` 
   HAVING `tagCount` = 0 
   ORDER BY `tagCount` DESC LIMIT 0,
   24) AS `File` 
   LEFT OUTER JOIN `FileTags` AS `tags-&gt;FileTags` 
   ON `File`.`id` = `tags-&gt;FileTags`.`fileId` 
   LEFT OUTER JOIN `Tags` AS `tags` 
   ON `tags`.`id` = `tags-&gt;FileTags`.`tagId` 
   ORDER BY `tagCount` DESC;
  </code></pre>