lib/mongoose/paginate.js
function handlePromise(query, q, model, resultsPerPage) {
  return Promise.all([
    query.exec(),
    model.count(q).exec()
  ]).spread(function(results, count) {
    return [
      results,
      Math.ceil(count / resultsPerPage) || 1,
      count
    ]
  });
}
function handlePromise(query, q, model, resultsPerPage) {
  return Promise.all([
    query.exec(),
    model.count(q).exec()
  ]).spread(function(results, count) {
    return [
      results,
      Math.ceil(count / resultsPerPage) || 1,
      count
    ]
  });
}
function handlePromise ( query , q , model , resultsPerPage ) { return Promise . all ( [ query . exec ( ) , model . count ( q ) . exec ( ) ] ) . spread ( function ( results , count ) { return [ results , Math . ceil ( count / resultsPerPage ) || 1 , count ] } ) ; }
Return a promise with results

@method handlePromise
@param {Object} query - mongoose query object
@param {Object} q - query
@param {Object} model - mongoose model
@param {Number} resultsPerPage
@returns {Promise}
Return a promise with results