code: function batchLoop(){
                  var promisesArray = createBatchJobs();
  
                  Q[qFunction](promisesArray).then(function(batchResult){
                      if(qFunction === "allSettled"){
                        batchResult = batchResult.filter(function(res){return res.state === "fulfilled"}).map(function(item){return item.value;})
                      }
  
                      results = results.concat(batchResult);
                      //these are upserted, let's check the next ones
                      if(!disableLogs) {
                          console.log("This squad is done, " + dataCopy.length + " items remaining");
                      }
                      if(dataCopy.length == 0){
                          if(!disableLogs){
                              console.log("Finished the batch loop");
                          }
                          deferred.resolve(results);
                      }else{
                          batchLoop();
                      }
                  }).catch(function(e){
                      if(!disableLogs) {
                          console.error(e);
                      }
                      deferred.reject(results);
                  });
              }
docs: the main loop creating batches of jobs