title: nodeJS return value from callback
body: <p>I am building an application in which on a particular call, i must block and wait for the results from an authentication query before coninuing.</p>
  
  <pre><code>function authenticate(userid, hash)
  {
      mysql_client.query("SELECT `hash` FROM `auth` WHERE `userid` = " + userid, function selectCb(err, results, fields) {
      if (err)
      {
        client.send("Error communicating with mysql, please retry your request");
        return false;
      }
  
      if(results.length == 0 || results[0].hash != hash)
      {
          client.send("Error comparing authentication data with database, please retry request");
          return false;
      }
  
      return true;
  }
  );
  }
  </code></pre>
  
  <p>I want to be able to return those values from the authenticate() function itself, not the internal anonymous function selectCb and have authenticate block until the callback is complete. How can I go about doing this?</p>