I am using sequelize (version 5.3.5) to connect to a postgre database and have configured the logging to use console.log
, but whenever a query with bounded parameters appears, I am unable to see which parameters are being bound.
The configuration is very standard.
import Sequelize from 'sequelize';
let db = new Sequelize (
"database", "username", "password",
{
dialect: 'postgres',
logging: console.log
}
);
Taking for example this log of an INSERT operation (inside a transaction):
Executing (a7ed97b4-66a2-43a2-b4c5-eaa067e7ec28): INSERT INTO "Entities" ("id","type","createdAt","updatedAt") VALUES ($1,$2,$3,$4) RETURNING *;
Is there a way to make sequelize show me what values are being mapped to $1
.. $6
?
I revisited this after a while, and with sequelize at version 5.19.0
I found that there is a property where all the bound values are stored.
Going back to it:
import Sequelize from 'sequelize';
let db = new Sequelize (
"database", "username", "password",
{
dialect: 'postgres',
logging: customLogger
}
);
function customLogger ( queryString, queryObject ) {
console.log( queryString ) // outputs a string
console.log( queryObject.bind ) // outputs an array
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With