title: Cannot display row count in node.js
body: <p>I am trying to run the following bit of code in <code>node.js</code> to display the number of tables in a postgresql database:</p>
  
  <pre><code>var pg = require('pg'); 
  var conString = "postgres://login:pwd@localhost/DB";
  var client = new pg.Client(conString);
  
  client.connect(function(err) {
      if (err) {
          console.error('Could not connect to DB', err);
      } else {
          console.log('Could connect to DB');
          client.query("SELECT * FROM pg_catalog.pg_tables", function(err, result) {
              if (err) {
                  console.error('Error with table query', err);
              } else {
                  var cnt = result.rows.length;
                  console.log("Row count: " + cnt.toString());
              }
          });
          console.log('After query');
          client.end();
      }
  });
  </code></pre>
  
  <p>Unfortunately, only the following is displayed in the console:</p>
  
  <pre><code>Could connect to DB
  After query
  </code></pre>
  
  <p>Why isn't the row count line displayed? How can I find out what the issue is?</p>