title: send multiple requests in parallel
body: <p>I have to make a bridge (script) between two databases (Mongo and Oracle).</p>
  
  <p>I run three find queries on my MONGO database in three different collections.</p>
  
  <pre><code> Collection 1 = [{
    name: 'Toto',
    from: 'Momo',
    note: 5,
    cat: 'noCategori'
   }]
  
   Collection 2 = [{
    city: 'london',
    country: 'UK'
   }]
   ...etc
  </code></pre>
  
  <p>I retrieve lists of documents from each collection I make a treatment on this list (Ex: average).</p>
  
  <pre><code>RowToSend = {
    name: 'Toto',
    note: 17, // average all document
    city: 'london'
  }
  </code></pre>
  
  <p>I establish a connection with Oracle and I persist this row.</p>
  
  <p>I would like to run queries to mongo in parallel. at the end of the three requests and treatments. I compose my recording and I persist it on my database.</p>
  
  <p>I have with async but it does not work. With await too. the function (Script) ends before the request is processed</p>
  
  <pre><code>function RequestOne(dateStart, dateEnd, RowToInsert) =
  
       CollectionOne.find({
          AQS_REF_TIME_EVENT_MSR: {
              $gte: startInterv,
              $lte: endInerv
          },
  
      })
      .exec((err, arrAqsOneHourMoy) =&gt; {
        if (err)
           return err;
        if (arrAqsOneHourMoy) {
           AttributeOneAverge = 0;
           AttributeTwoAverage = 0;
  
         for (i = 0; i &lt; arrAqsOneHourMoy.length; i++) {
                  AttributeOneAverge = (arrAqsOneHourMoy[i].AttributeOne + AttributeOneAverge);
                  AttributeTwoAverge = (arrAqsOneHourMoy[i].AttributeTwo + AttributeTwoAverge);
              }
  
        RowToInsert.AttributeOne = ((AttributeOneAverge) / (i + 1));
        RowToInsert.AttributeOne = (AttributeTwoAverge) / (i + 1);
        }
      })
  } 
  </code></pre>
  
  <p>Function TWO .. same logic</p>
  
  <p>Globale function : </p>
  
  <pre><code>function GenericFunction(time, sensorID, TEST_oracle_save) {
  var d = new Date(2018, 00, 03, 11, 00, 00, 000);
  var x = d.toISOString();
  
  var d2 = new Date(2018, 00, 03, 11, 59, 59, 999);
  var y = d2.toISOString();
  
  
  RequestOne(x, y, TEST_oracle_save);
  RequestTwo(x, y, TEST_oracle_save);
  
  
  //Connexion to ORACLE DATABASE 
  
  //Connexion etablished 
  
  // Persist TEST_oracle_save on field Oracle
  }
  </code></pre>