Skip to content
brianc edited this page Oct 29, 2010 · 66 revisions

Basically a facade on top of the connection to provide a much more user friendly, "node style" interface for doing all the lovely things you like with PostgreSQL.

Now that I've got the Connection api in place, the bulk and meat of the work is being done on the Client to provide the best possible API. Help? Yes please!

var client = new Client({
  user: 'brian',
  database: 'postgres',
});

client.query("create temp table ids(id integer)");
client.query("insert into ids(id) values(1)");
client.query("insert into ids(id) values(2)");
var query = client.query("select * from ids", function(row) {
  row.fields[0] // <- that equals 1 the first time. 2 the second time.
});
query.on('end', function() {
  client.end();
});    

Clone this wiki locally