title: NodeJS Promises - "Then" not called
body: <p>I'm new to NodeJS and after spending a few hours trying to understand how Promises work exactly, what seems to be an easy thing still doesn't work.</p>
  
  <p>I'm trying to make a few calls to a database, and once all of those calls are done, do something else. What I have now is the following code, but none of the then-functions are called.</p>
  
  <pre><code>var queries = ['SELECT value FROM tag', 'SELECT url FROM download_link'];
  console.log("Starting promises");
  var allPromise = Promise.all([queryDatabaseAddToResult(connection, queries[0], result), queryDatabaseAddToResult(connection, queries[1], result)]);
    allPromise.then(
      function(result) {
        console.log("1");  // Does not show up
      }, function(err) {
        console.log("2");  // Does not show up either
      }
    );
  
  function queryDatabaseAddToResult(connection, query, result) {
    return new Promise(function(resolve, reject) {
      connection.query(query, function(err, rows, fields) {
        if (err) {
          console.log(err);
          Promise.reject(err);
        }
        console.log(rows);
        result.tags = JSON.stringify(rows);
        Promise.resolve(result);
     });  
  })
  </code></pre>
  
  <p>}</p>
  
  <p>The calls to the database do get made, as logging the rows show up in the log.</p>