title: prepared statements node-postgresql error with null result
body: <p>i am new in node.js and postgresql. am allready connected with postgres db and execute some test code. after am going to use prepared statements.am create a sample login script. if user exist it return username else return message "invalid username or password". if username and password is correct,it return username. but no data will present , then could not return message. my openion is that , the control will crashed after executing cliend.end() function. </p>
  
  <p>this is my code</p>
  
  <pre><code>UserLogin.get = function(userName, callBack) {
      pg.connect(pgConString, function(err, client, done) {
          if (err) {
              callBack("DB connection failed. " + err, null);
              return;
          }
          var selectQuery="SELECT * from  "  + TABLE + " WHERE userName=($1)";
          var query=client.query({
                  text:selectQuery,
                  values:[userName],
                  name:"selectQuery"});
  
                  query.on("error", function (error) {
                   callBack("DB fetch failed. Error Message: " + err, null);});
  
                  query.on('row', function(row) {
                  callBack(null, row);});
  
                  query.on("end", function (result) {
                  client.end();
                  return;
                   });
              });     
  }
  </code></pre>
  
  <blockquote>
    <p>if row is empty, not return to callback. if row_result is not empty, its working fine.. How...????  any idea...???</p>
  </blockquote>