If you want to use connection object for query database you can use this sample code.
var queryString = "SELECT name, age FROM students " ;
var query = client.query(queryString);
query.on("row", (row, result)=> {
result.addRow(row);
});
query.on("end", function (result) {
//LOGIC
});