diff --git a/FAQ.md b/FAQ.md index d96893e..bf3a2a8 100644 --- a/FAQ.md +++ b/FAQ.md @@ -39,11 +39,18 @@ client.query(..., function(err, result) { ### 4. How do you get the count of columns in the result set ? ### ```js -pg.query(..., function(err, result) { +client.query(..., function(err, result) { var columnCount = Object.keys(result.rows[0]).length; }); ``` +This may also be accomplished using the `result.fields` array: +```js +client.query(..., function(err, result) { + var columnCount = result.fields.length; +}); +``` + ### 5. If pg returns query data in JSON format, for web service applications, it would make sense to return that directly to the client. If this assumption is correct what is the most efficient method? ### ```js