diff --git a/lib/index.js b/lib/index.js index 55414c6..18b5306 100644 --- a/lib/index.js +++ b/lib/index.js @@ -181,7 +181,7 @@ class Service { if (!params.knex) { this.knexify(countQuery, query); } - return countQuery.then(count => count[0].total).then(executeQuery).catch(errorHandler); + return countQuery.then(count => count[0] ? count[0].total : 0).then(executeQuery).catch(errorHandler); } return executeQuery().catch(errorHandler);