Knex.js - SQL Debugging Only

Is there a way to display only SQL queries on the console when debug mode is on? I want to reduce the amount of information that is displayed.

Thanks for the help;)

+4
source share
3 answers

Actually, if you use MySQL, you can install

debug: ['ComQueryPacket']

as part of the configuration settings for mysql (not Knex).

I will consider this as an option in Knex.

+4
source

Set the environment variables to configure the module debug:

  • DEBUG=knex:query for just inquiries
  • DEBUG=knex:tx for transactions
  • and DEBUG=knex*for everyone.
+8
source

, , , "", Knex .

:

var knex = require( 'knex' );
knex.on( 'query', function( queryData ) {
    console.log( queryData );
});

, queryData json .

+5
source

All Articles