Static method into Model

I want to use a static method into a model for after I can call this method in a Ace command but the method not works. Can somebody help me?

This is the code.

static async checkpointForZone(day) {
        const zonesForDay = await this.query().with('points').where(day, 1).fetch();
        return zonesForDay;

This is the error

Promise { <pending> }
  WARNING: Adonis has detected an unhandled promise rejection, which may
  cause undesired behavior in production.
  To stop this warning, use catch() on promises or wrap await
  calls inside try/catch.

Error: aborted
    at PendingOperation.abort (/Users/yasser/Proyectos/yoreciclo/node_modules/tarn/lib/PendingOperation.js:23:21)
    at /Users/yasser/Proyectos/yoreciclo/node_modules/tarn/lib/Pool.js:138:25
    at (<anonymous>)
    at /Users/yasser/Proyectos/yoreciclo/node_modules/tarn/lib/Pool.js:137:53
From previous event:
    at Client_MySQL.acquireConnection (/Users/yasser/Proyectos/yoreciclo/node_modules/knex/lib/client.js:334:34)
    at Runner.ensureConnection (/Users/yasser/Proyectos/yoreciclo/node_modules/knex/lib/runner.js:228:24)
    at (/Users/yasser/Proyectos/yoreciclo/node_modules/knex/lib/runner.js:34:42)
    at Builder.Target.then (/Users/yasser/Proyectos/yoreciclo/node_modules/knex/lib/interface.js:20:43)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
1 Like

Nothing, same error

Static methods doesn’t have context, so you cannot use this.

async checkpointForZone(day) {
        const zonesForDay = await YourModel.query().with('points').where(day, 1).fetch();
        return zonesForDay;

I don’t get what’s the issue here?

It’s not related with Adonis. User tried to use this with static function