title: Sequelize - Count Based on Include Condition
body: <p>I'm using the <code>sequelize</code> <code>count</code> function as follows:</p>
  <p>Definition:</p>
  <pre><code>const countAllOrdersWhere = async (conditions) =&gt;
      Order.count({
          where: conditions,
      })
          .then((count) =&gt; ({ count, error: null }))
          .catch((error) =&gt; ({ count: null, error }));
  </code></pre>
  <p>Usage:</p>
  <pre><code>  const { count, error: countError } = await countAllOrdersWhere({
                      [Op.or]: [
                          { userId: userIds, status },
                          { status, venueId },
                      ],
                  });
  </code></pre>
  <p>This works great, however I now need to add a condition based on an associated model:</p>
  <ol>
  <li>Each <code>order</code> has many <code>orderItems</code> associated with it (there's an <code>orderId</code> on each row in the <code>orderItem</code> table.)</li>
  <li>Each <code>orderItem</code> has one <code>item</code> associated with it - (there's an <code>itemid</code> on each row in the <code>orderItem</code> table.)</li>
  </ol>
  <p>I have an array of <code>itemIds</code> and I would like to only count the orders which are associated with an <code>orderItem</code> which has an <code>itemId</code> which is in my list.</p>
  <p>When querying the <code>orders</code>, I enforce this clause in a <code>findAll</code> function by doing</p>
  <pre><code>include: [
   {
   model: OrderItem,   
   where: Sequelize.literal(
        itemIds &amp;&amp; itemIds.length &gt; 0
        ? `&quot;orderItems&quot;.&quot;itemId&quot; IN (${itemIds})`
        : 'true'
   )}]
  </code></pre>
  <p>however, I'm not sure how to do this in a <code>count</code> function</p>