mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Added alternate answer to #4, and made a minor correction to the original answer.
parent
6c005061a6
commit
aaa45dfd1e
9
FAQ.md
9
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user