title: Proper asynchronous mysql query in nodejs?
body: <p>Completely new to nodejs, having trouble wrapping my head around asynchronous programming/callbacks. What I'm trying to do is:</p>
  
  <p>On 'post', I want to gather all the words in a table in my database. I call it like so: <code>var lesson_data = init_load_lesson();</code> This call to <code>init_load_lesson()</code> is from index.js in my 'routers' file made my express.</p>
  
  <p>How do I construct a proper callback so that lesson_data is the results of my query?</p>
  
  <pre><code>var mysql = require('mysql'); 
  var connection = require('./connection'); 
  
  var data = [];
  
  function init_load_lesson()
  {
    connection.connect();
  
    var queryString = "SHOW COLUMNS FROM LessonOneVocabulary";
  
    connection.query(queryString, function(err, rows, fields) {
      if (err) throw err;
      else
      {
        for (var i in rows)
        {
          data.push(rows[i].Fields);
          console.log(data);
        }
        console.log(data);
      }
    });
  
    connection.end();
  }
  
  
  module.exports = function() {
    load_lesson();
  };
  </code></pre>