Skip to content

Instantly share code, notes, and snippets.

@gusflopes
Last active May 14, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gusflopes/0b6e425e0e83d5550e833d9c571f1b22 to your computer and use it in GitHub Desktop.
Save gusflopes/0b6e425e0e83d5550e833d9c571f1b22 to your computer and use it in GitHub Desktop.
Adonis V5 useful - tips

We can pass this Env File to debug Adonis:

LOG_LEVEL=trace

To show the SQL Queries we can use this setting:

// AppProvider.ts
public async ready () {
    // App is ready
    const Application = (await import('@ioc:Adonis/Core/Application')).default
    const Event = (await import('@ioc:Adonis/Core/Event')).default

    const Logger = (await import('@ioc:Adonis/Core/Logger')).default
    const Database = (await import('@ioc:Adonis/Lucid/Database')).default

    Event.on('db:query', (query: any) => {
      if (Application.inProduction) {
        Logger.debug(query)
      } else {
        Database.prettyPrint(query)
      }
    })
  }
  
  // config/database.ts
  pg: {
    debug: !Application.inProduction,
    // rest
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment