Skip to content

Commit b99cc00

Browse files
scr_ecto-103 | Improve options/configuration described in README.
1 parent 608ea86 commit b99cc00

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,35 @@ page =
6666
|> MyApp.Repo.paginate(page: 2, page_size: 5)
6767
```
6868

69+
## Supported Options
70+
71+
There are several options that can be supplied in a dedicated `options` keyword list arg. Here is an example of using `options`...
72+
73+
```elixir
74+
defmodule MyApp.Repo do
75+
use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.Postgres
76+
use Scrivener, options: [allow_overflow_page_number: true]
77+
end
78+
```
79+
80+
Here is an explanation of the supported options...
81+
82+
* `:allow_overflow_page_number` - If set to true then when you supply a page greater than the total pages, it will return an empty list for entries. If set to false then it will (silently) treat any supplied `page` arg as if it was equal to the total pages. Default is false.
83+
84+
## Other Configuration
85+
86+
The behaviour of Ecto Scrivener can also be optionally configured by passing things directly to the `use Scrivener` statement rather than via the `options` keyword list arg. For example...
87+
88+
```elixir
89+
defmodule MyApp.Module do
90+
use Scrivener, page_size: 5, max_page_size: 100
91+
end
92+
```
93+
94+
Here is an explanation of the directly configurable keys...
95+
96+
* `:max_page_size` - This (silently) enforces a hard ceiling for the page size, even if you allow users of your application to specify page_size via query parameters. If not provided, there will be no limit to page size.
97+
6998
## Installation
7099

71100
Add `scrivener_ecto` to your `mix.exs` `deps`.

0 commit comments

Comments
 (0)