title: Promise.all is returning an array of undefined
body: <p>I am having trouble with function returning an array of undefined.</p>
  
  <p>Here is code: </p>
  
  <pre><code>classMethods.getQueries = function(models, dbId, dateStart, dateEnd) {
    return new Promise(function(resolve, reject) {
  
      /* Fetch database .... */
      .then(extractQueries, reject)
      .then(sortQueries, reject)
      .then(onlyTen, reject)
      .then(addText, reject)
      .then(function(queries) {
        console.log('getQueries finished', queries) ;  //array of 10 undefined! 
        resolve(queries);
      }, reject);
  
      /* Functions here .... */
  
    });
  };
  </code></pre>
  
  <p>Everything is fine until the addText function:</p>
  
  <pre><code>function addText(queries) {
    return Promise.all(queries.map(function(query) {
  
      models.queries.findById(query.queryId, { raw: true, attributes: ['query'] })
      .then(function(queryFetched) {
        query.text = queryFetched.query;
        console.log(query);
        return Promise.resolve(query);
      }, function(error) {
         return Promise.reject(error);
      });
  
    }));
  };
  </code></pre>
  
  <p>This is giving me an oupout like: </p>
  
  <pre><code>getQueries finished [undedfined 10x]
  
  10x  
  [query database]
  {queryId: ***, text: ********}
  </code></pre>
  
  <p>I have no idea why the promise is return while the loop is not finished.</p>
  
  <p>Thanks for the help.</p>