I am trying to come up with the node.js code to get the output of this query:
const viewAllEmployees = () => { let sql = 'SELECT e.id, e.first_name, e.Last_name, r.title, d.name as "Department", salary, CONCAT (m.first_name," ", m.last_name) AS "Manager" FROM employee e ' + connection.escape('INNER JOIN employee m ON e.manager_id = m.id LEFT JOIN role r ON e.role_id = r.id LEFT JOIN department d on r.department_id = d.id'); connection.query(sql, (err, res) => { if (err) throw err; console.table(res); // console.log(res); //connection.end(); });
The problem is that when I use it without the connection.escape(), I get the output, but with single quotes like this:
How can I (1) get rid of the (index) column, and (2) get rid of the single quotes? Getting rid of the single quotes is really the priority.
Thanks!
Advertisement
Answer
Index column and quotes are added by console.table
function itself.
You can check it running console.table with any static data like here: https://developer.mozilla.org/en-US/docs/Web/API/Console/table#collections_of_primitive_types
To print it in a way you want it, implement printing function on your own.