Query with Connection Object

suggest change

This sample uses a node-postgres client. It matches node-postgres 6 and earlier, where client.query returned a query you could listen to. In pg 7 and later, client.query(text) returns a promise and the result already contains rows.

var queryString = "SELECT name, age FROM students";
var query = client.query(queryString);

query.on("row", function (row, result) {
  result.addRow(row);
});

query.on("end", function (result) {
  // result.rows is available here
});

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents