title: Angularjs, undefined data returned from a Factory
body: <p>Just a quick question.</p>
  
  <p>I have this <strong><code>factory</code></strong>:</p>
  
  <pre><code> angular.module('app.services').factory('DatabaseFactory', 
   function($log, $q, DB_CONFIG, CATEGORY_CONFIG, $http, $webSql) {
    var self = this;
    self.db = null;
  
    self.init = function() {
      self.db = $webSql.openDatabase (DB_CONFIG.name, '1.0', 'database', 2 * 1024 * 1024);
      self.db.createTable('QuestionIndex', {
        'id':{
          'type': 'INTEGER',
          'null': 'NOT NULL', // default is 'NULL' (if not defined)
          'primary': true, // primary
          'auto_increment': true // auto increment
        },
        'question_id': {
          'type': 'INTEGER'
        },
        'oltre': {
          'type': 'INTEGER'
        },
        'section_id': {
          'type': 'INTEGER'
        },
        'errors_count': {
          'type': 'INTEGER'
        },
        'done_count': {
          'type': 'INTEGER'
        }
  
      }); 
  
    };
  
    self.getAll = function() { 
      self.db.select('QuestionIndex',{"oltre":'IS NOT NULL'}).then(function(results) {
        var records = [];
        for(var i=0; i &lt; results.rows.length; i++){
          records.push(results.rows.item(i));
        };
        $log.info(records); 
        return records;
      }); 
    };
  
    return self;
  
  });
  </code></pre>
  
  <p>I'm injecting this factory in another factory and I must retrieve the data calling <code>getAll</code>function. </p>
  
  <pre><code>angular.module('app.services')
    .factory('QuizCreate', ['DatabaseFactory','$log', function(DatabaseFactory,$log){
      self.generateQuiz = function() {
        $log.info(DatabaseFactory.getAll());
      };
      return self;
    }]);
  </code></pre>
  
  <p>The first log entry return me all the objects, the query is working fine. I can't understand why my the second log return me <code>undefined</code>. </p>
  
  <p>Why I can't return my data from the first Factory?</p>