View Source LimitOffsetPaginator (LimitOffsetPaginator v1.1.1)

LimitOffsetPaginator adds one function to your Repo - paginate. To use this function, you need to make use of the use macro in your Repo module. It needs to receive the module itself as a repo parameter. Together with that, you can add your default limit, offset, and field by which the list will be ordered by. There are also four extra options: enable_custom_field, when set to true, enables the user to change the order by field by passing a field variable into the params. It is false by default; enable_custom_limit, when set to true, enables the user to change the limit in the query by passing a limit variable into the params. It is true by default; enable_custom_offset, when set to true, enables the user to change the offset in the query by passing an offset variable into the params. It is true by default; show_count_by_default, when set to true, makes it so that you must pass show_count: false in order to not receive the total counts, for more info on show_count see the doc on paginate from your Repo.

Example

defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :me_app,
    adapter: Ecto.Adapters.Postgres

  use LimitOffsetPaginator,
    repo: MyApp.Repo
end