title: Firebase query function returns undefined
body: <p>I want to write a query function which returns an object. The problem is, in my case the function returns <code>undefined</code>.</p>
  
  <pre><code>var filterDataAccordingToDate = function (ref, startTime, endTime) {
  
      var filteredObj = {};
  
      ref.orderByChild('date').startAt(startTime).endAt(endTime)
      .once('value', function(snap) {
         filteredObj = snap.val();
  
         console.log(util.inspect(filterDataAccordingToDate(filteredObj, false, null));
        //Returns the correct object
  
         return filteredObj;
      });  
  }
  
  console.log("DATA RETURNED: " + util.inspect(filterDataAccordingToDate(travelRef, 1466439004, 1466439011), false, null));
  // DATA RETURNED: undefined
  </code></pre>