Looking at the source code (https://github.com/brianc/node-postgres/blob/master/lib/client.js#L331), the query
method returns a Query object. So you should be able to do something like this:
var query = client.query('SELECT $1::int AS number', ['1'], function(err, result) {
if (err) {
var sql = query.text;
}
}
(assuming your callback function is in the same scope as query
).
Disclaimer: I've never used node-postgres.