mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-25 16:03:13 +00:00
Updated FAQ (markdown)
parent
69b7fb7ffb
commit
2d8c8d5168
14
FAQ.md
14
FAQ.md
@ -30,7 +30,17 @@ client.query(..., function(err, result) {
|
||||
|
||||
### 4. (Alert! Possibly an idiot question) How do you get the count of columns in the result set ? ###
|
||||
|
||||
### 5. (Alert! Possibly an idiot question) If pg returns query data in JSON format, for web serivce applications, it would make sense to return that directly to the client. If this assumption is correct what is the most efficient method? ###
|
||||
|
||||
### 5. If pg returns query data in JSON format, for web serivce applications, it would make sense to return that directly to the client. If this assumption is correct what is the most efficient method? ###
|
||||
```js
|
||||
http.CreateServer(function(req, res) {
|
||||
//NOTE: pg connection boilerplate not present
|
||||
pg.query(..., function(err, result) {
|
||||
//NOTE: error handling not present
|
||||
var json = JSON.stringify(result.rows);
|
||||
res.writeHead(200, {'content-type':'application/json', 'content-length':json.length});
|
||||
res.end(json);
|
||||
});
|
||||
})
|
||||
```
|
||||
|
||||
Thank you Brian. pg is excellent.
|
||||
Loading…
x
Reference in New Issue
Block a user