title: Promise.all array of promises
body: <p>I have this code:</p>
  
  <pre><code> db.group.findOne({_id: id}).then((groupFound) =&gt; {
       var membersArray = groupFound.members;
  
       Promise.all(membersArray.map((member) =&gt; {
           return db 
              .doneTodo
              .find({'victor._id': member._id})
              .then((userVictories) =&gt; {
                  return {
                      email: member.email,
                      victories: userVictories.length
                  }
              });
      })).then(function (result) {
          console.log(result);
      });
  </code></pre>
  
  <p>The db calls are all MongoDB/Mongoose. </p>
  
  <p>The inside of the array returned from the <strong>map</strong> function is all promises.</p>
  
  <p>The last call:</p>
  
  <pre><code>.then((userVictories) =&gt; {
      return {
          email: member.email,
          victories: userVictories.length
      }
  })
  </code></pre>
  
  <p>returns a promise. </p>
  
  <p>So essentially, after this call is made, what I have is:</p>
  
  <pre><code>[promise1, promise2, promise3, ... , promise x]
  </code></pre>
  
  <p><strong>How are</strong> these promises concluded to change the array value to the value of <code>promise1.then( (result))</code>?</p>