title: Variable outside of callback in NodeJS
body: <p>I am fairly new to NodeJS and to JavaScript in general. Here is my script:</p>
  
  <pre><code>var data = [];
  
      client.query(
  
        'SELECT * FROM cds',
        function selectCb(err, results, fields) {
  
          if (err) {
            throw err;
          }
  
          console.log(results);
          console.log(fields);
  
          data.push(results);
        }
      );
  
      console.log(data);
  </code></pre>
  
  <p>How can I get access to the <code>results</code> (or <code>data</code>) var outside of the callback? I don't want to have to write a ton of callbacks inside of each other when running queries.</p>