Query from PouchDB, promise won't show up

Hello, I’m writting app and I’m using PouchDB as local storage for record. I’m trying to understand why it won’t work. This is query function in my factory, I have a problem with that if I remove the return from line (return db.query), then I can’t get promise in controler. I tried to google it, but I can’t get explanation.

Thanks :]

Drives.query().then(function(drives) {
console.log(drives);
$scope.drives = drives;
});


Factory function for query from PouchDB

query: function() {
  function map(doc) {
    if (doc) {
      emit(doc);
    }
  };

  
  return db.query({   // If I remove this return, 
    map: map          // then controller promis don't show up
  }, {
    reduce: false
  }).then(function(doc) {
    console.log(doc);
    log.debug('Doing query...');
    var drives = [];
    angular.forEach(doc.rows, function(value, key) {
      log.debug(value.key);
      drives.push(value.key);
    });
    return drives;
  })
}

I know why it’s not working, becouse I’m not returning promise. I tried some examples from angularjs webpage and it don’t work. :smile: