From b875549df5b5ece2cac3e65fb3e1172194e978fb Mon Sep 17 00:00:00 2001 From: brianc Date: Tue, 31 May 2011 15:16:33 -0700 Subject: [PATCH] Updated FAQ (markdown) --- FAQ.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index a932ccc..e588f2e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -74,4 +74,18 @@ or for the native client 2. `var Client = require('pg').native.Client;` -Thank you Brian. pg is excellent. \ No newline at end of file +Thank you Brian. pg is excellent. + + +### 7. I just have a question and maybe a feature request that i am not able to think about how to implement or do it: i need to retrieve the inserted row or someway to reach it after the insert is done. + +Yeah, you can do this as so: +```js +//let's pretend we have a user table with the 'id' as the auto-incrementing primary key +client.query('INSERT INTO users(password_hash, email) VALUES($1, $2) RETURNING id', function(err, result) { + if(err) //handle error + else { + var newlyCreatedUserId = result.rows[0].id; + } +}); +``` \ No newline at end of file