Database.HaskellDB.Pagination (annotation)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{-# LANGUAGE RecordWildCards #-}

-- | Pagination utilities.

module Database.HaskellDB.Pagination where

import Database.HaskellDB.Query

import Data.Pagination

-- | Paginate a query.
paginate :: Pagination -> Query ()
paginate Pagination{..} = do
  offset (fromIntegral $ (pnCurrentPage-1) * pnPerPage)
  top (fromIntegral pnPerPage)