How get counts of rows with limit and offset for use it in pagination?

Hi every one.
I am using this query for promotions list, and i want add the pagination to it,i used forPage(page,limit) method and it worked correctly for limit and offset,but how i can get total number of rows for use total result in pagination?

 var promotions = await Database    
 .select('Promotion.*','Country.title as country','Province.title as province','Status.code as statusCode','Status.title as statusTitle','Currency.symbol as currency')
 .join('Status', 'Promotion.statusId', '')
 .join('Currency', 'Promotion.valueCurrencyId', '')
 .join('Country', 'Promotion.countryId', '')
 .leftJoin('Province', 'Promotion.provinceId', '')
 .where(function () {
      if(request.qs && request.qs.statusId && request.qs.statusId!=0)
         this.where('statusId', request.qs.statusId) 
         this.whereNotIn('statusId', [3,4])  
         this.where('', request.body.promotionId)
      else if(params.promotionId)
         this.where('', params.promotionId)

I use paginate method :heart_eyes:

1 Like