title: How to extend sequelize class methods?
body: <p>Is it possible to extend my sequelize model to have methods other than <code>findAll</code> or <code>findOne</code>.</p>
  <p>I want to have something like:</p>
  <pre class="lang-js prettyprint-override"><code>class Transaction extends Model {
    
    static associate(models) {
      this.belongsTo(models.StripePayment, {
        foreignKey: 'stripePaymentId',
        as: 'stripePayment',
      });
    }
      
    async failedTransactions({
      billId
    }) {
      return this.findAll({
        where: {
          billId
        },
        include: [
          {
            model: StripePayment,
            required: false,
          },
        ],
      });
    },
    
    // ...
  }
  </code></pre>
  <p>Where I can then call</p>
  <pre class="lang-js prettyprint-override"><code>const failedTransactions = await Transaction.failedTransaction({ billId }) // currently throws Transaction.failedTransaction is not a function
  </code></pre>
  <p>Is seems to recognise it as a function if I define the method as static inside the model</p>
  <pre class="lang-js prettyprint-override"><code>static async failedTransactions({
      billId
    }) {
      ...
    }
  </code></pre>
  <p>However, the associations don't seem to work inside a static method. I am guessing this is because the method gets defined before my model links it's associations.*</p>
  <ul>
  <li>associations work when I call the <code>findAll</code> query in my controller (i.e. not in the model)</li>
  </ul>