The following code does not really do what I want.
function doIt () {
  return new Promise (function (resolve, reject) {
    var promises = [];
    db.transaction(function(tx1){
      tx1.executeSql(function(tx2, rs) {
        for (var i = i; i < N; i++) {
          promises.push(db.transaction(function(tx3){
            ...
          }));
        }
      });
    });
    Promise.all(promises).then(resolve);
  });
}
Now it does not work, because Promise.all() gets executed, before all promises are in the array, at least I think that's correct.
Is there a elegant way to guarantee that all these promises are finished, before doIt ends?
 
    