how to get paginated select on slick + postgresql
You can use take
and drop
methods on TableQuery
objects. They will be translated to limit
and offset
in the resulting SQL query:
val users: TableQuery[UsersTable] = UsersTable.queryval firstPartOfUsers = users.drop(0).take(25).resultval secondPartOfUsers = users.drop(25).take(25).result
Those two actions will be translated to the following SQL queries:
select "name", "email", "id" from "users" limit 25 offset 0select "name", "email", "id" from "users" limit 25 offset 25