title: nodeJS / Express: what's wrong with this RSVP promise?
body: <p>I'm using nodeJS, running express4 framework to create an API. I am using RSVP.js for promises.</p>
  
  <p>worker.getFamilies is called by an external module, not reflected here. The caller expects back an object with results.</p>
  
  <p>Inside worker.getFamilies:
  - I am querying mongoDB using mongoose (works, we get results back)</p>
  
  <ul>
  <li><p>I am using a promise to get the response object from mongoose when its available. That works. </p></li>
  <li><p>Then I try to return JSON.stringify(results); to the caller of worker.getFamilies and that doesnt work. The caller gets back "undefined". please help.</p>
  
  <pre><code>var worker = exports;
  var RSVP = require('rsvp');
  
  var getFamiliesFromDB = function(DBconnection){
      var promise = new RSVP.Promise(function(resolve, reject){
          DBconnection.find({} ,{limit:10, sort: [['_id',-1]]}).toArray(function(e, results){ 
              console.log('results:', results);
              resolve(results);
          });   
      });
      return promise;
  }
  
  worker.getFamilies = function(DBConnection){
      getFamiliesFromDB(DBConnection).then(function(results){
  
          //this works
          console.log('here are the fams from the promise', results);
  
          //this doesnt work like i want it to
          return JSON.stringify(results);
      });  
  };
  </code></pre></li>
  </ul>