title: Node Js & Blubird for concurrent mysql requests
body: <p>My goal is to make a first query to retrieve dates and send result via socket.emit.  Then for each date, make a second request and also send result via socket.emit after each request.</p>
  
  <p>By now I have </p>
  
  <pre><code>var Promise    = require("bluebird");
  var mysql      = require('mysql')
  Promise.promisifyAll(require("mysql/lib/Connection").prototype);
  Promise.promisifyAll(require("mysql/lib/Pool").prototype);
  
  var pool = mysql.createPool({
  connectionLimit : 10,
  host : MYSQL_HOST,
  database : MYSQL_DB,
  user : MYSQL_USER,
  password : MYSQL_PASS
  })
  
  var list
  var pool_connection
  
  pool.getConnectionAsync()
  .then( (connection) =&gt; { 
      var query = "select ..."
      pool_connection = connection
      return connection.queryAsync(query)
   }) // step 1
  .then( (rows) =&gt; { 
      list = []
      rows.forEach( (row) =&gt; { 
          list.push(row.added)
          socket.emit('...',{added:row.added})
      })
      return new Promise((resolve) =&gt; { resolve(true) })
  }) // step 2
  .then( (result) =&gt; {
      var promises = []
      list.forEach( (date) =&gt; {
          var query = "..."
          promises.push(pool_connection.queryAsync(""+query+""))
      })
      return Promise.all(promises)
  }) // step 3
  .then( (result) =&gt; { socket.emit('...',result })
  .catch( (error) =&gt; { console.log(error) } )
  </code></pre>
  
  <p>It is working, but can I do to send (via socket.emit) after each query ?</p>