Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. paginateQuery :: Pagination -> Query a -> Query a
  2. paginateQuery (Pagination p w) = limit p . offset ((p-1) * w)
  3.  
  4. paginate
  5. :: (CanOpaleye c e m, Default QueryRunner a b)
  6. => Pagination
  7. -> (a -> Column i)
  8. -> Query a
  9. -> m (PaginationResults b)
  10. paginate p getId q = do
  11. res <- liftQuery $ paginateQuery p q
  12. c <- liftQueryFirst . aggregate count . fmap getId $ q
  13. return $ PaginationResults
  14. (p^.paginationPage)
  15. (p^.paginationWidth)
  16. (fromMaybe 0 c)
  17. res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement