Skip to content

Commit 27415f3

Browse files
committed
docs(readme): add pagination example
1 parent cc3f11d commit 27415f3

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,34 @@ services.AddJsonApi<AppDbContext>(
164164
opt => opt.Namespace = "api/v1");
165165
```
166166

167-
## Pagination
168-
169-
If you would like pagination implemented by default, you can specify the page size
170-
when setting up the services:
171-
172-
```csharp
173-
services.AddJsonApi<AppDbContext>(
174-
opt => opt.DefaultPageSize = 10);
175-
```
176-
177167
## Defining Custom Data Access Methods
178168

179169
You can implement custom methods for accessing the data by creating an implementation of
180170
`IEntityRepository<TEntity, TId>`. If you only need minor changes you can override the
181171
methods defined in `DefaultEntityRepository<TEntity, TId>`. The repository should then be
182172
add to the service collection in `Startup.ConfigureServices` like so:
183173

184-
```
174+
```csharp
185175
services.AddScoped<IEntityRepository<MyEntity,Guid>, MyEntityRepository>();
186176
```
187177

178+
## Pagination
179+
180+
Resources can be paginated.
181+
The following query would set the page size to 10 and get page 2.
182+
183+
```
184+
?page[size]=10&page[number]=2
185+
```
186+
187+
If you would like pagination implemented by default, you can specify the page size
188+
when setting up the services:
189+
190+
```csharp
191+
services.AddJsonApi<AppDbContext>(
192+
opt => opt.DefaultPageSize = 10);
193+
```
194+
188195
## Filtering
189196

190197
You can filter resources by attributes using the `filter` query parameter.
@@ -206,7 +213,6 @@ identifier):
206213
?filter[attribute]=ge:value
207214
```
208215

209-
210216
## Sorting
211217

212218
Resources can be sorted by an attribute:

0 commit comments

Comments
 (0)