title: How do I return data from a function in Node that connects to Mongodb?
body: <pre><code>function getEmployees(jobID){
      MongoClient.connect(url, function(err, db){
          if(err) throw err;
          var dbo = db.db("mydb");
          dbo.collection("employees").find({employee:jobID}).toArray(function(err, result){
              if(err) throw err;
              db.close();
              console.log(result) // shows the employees. cool!
              // how do I return result??
          })
      })
  }
  var employees = getEmpoyees(12345);  // I want the employees variable to be an array of employees
  </code></pre>
  
  <p>I'm new to node.js and javascript and I can't figure this out. Do I need to implement a callback to use the data the way I'm trying to? </p>