Search code examples
node.jsnode-oracledb

Can we log a SQL query having bind parameters in node-oracledb?


const query = `INSERT INTO countries VALUES (:country_id, :country_name)`;
try {
    const result = await connection.execute(query, { country_id: 90, country_name: "Tonga" });
} catch (error) {
    console.error(`error while executing: ${query}`);
}

Is there any way to log the query along with the bind parameters data
so that I can log INSERT INTO countries VALUES (90, "Tonga")


Solution

  • Eventually, I found a package known as bind-sql-string which has queryBindToString method that solves my problem. 🎉