Skip to content

Commit 102e728

Browse files
committed
Clarify pagination usage with Entity Service API
Improves upon #1837
1 parent e361e16 commit 102e728

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

docusaurus/docs/dev-docs/api/entity-service/order-pagination.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,22 @@ strapi.entityService.findMany('api::article.article', {
6464

6565
## Pagination
6666

67-
To paginate results returned by the Entity Service API, you can use the `start` and `limit` parameters:
67+
Results can be paginated using 2 different strategies (see [REST API documentation](/dev-docs/api/rest/sort-pagination#pagination) for more details):
68+
69+
- pagination by page, when defining the `page` and `pageSize` parameters,
70+
- and pagination by offset, when defining the `start` and `limit` parameters.
71+
72+
2 different functions can be used to paginate results with the Entity Service API, and accept different pagination strategies: `findMany()` and `findPage()`
73+
74+
| Function name | Possible pagination method(s) |
75+
| ------------- | ----------------------------------------------------------- |
76+
| `findMany()` | Offset pagination only |
77+
| `findPage()` | <ul><li>Offset pagination</li><li>Page pagination</li></ul> |
78+
79+
<Tabs>
80+
<TabItem value="find-many" label="findMany()">
81+
82+
`findMany()` should only be used with offset pagination:
6883

6984
```js
7085
strapi.entityService.findMany('api::article.article', {
@@ -73,11 +88,35 @@ strapi.entityService.findMany('api::article.article', {
7388
});
7489
```
7590

76-
You may instead use the `page` and `pageSize` parameters:
91+
</TabItem>
92+
<TabItem value="find-page" label="findPage()">
93+
94+
`findPage()` accepts both offset and page pagination, provided you use only one pagination strategy per query:
95+
96+
<Tabs>
97+
<TabItem value="offset-pagination" label="Offset pagination">
7798

7899
```js
79-
strapi.entityService.findMany('api::article.article', {
100+
strapi.entityService.findPage('api::article.article', {
101+
start: 10,
102+
limit: 15,
103+
});
104+
```
105+
106+
</TabItem>
107+
108+
<TabItem value="page-pagination" label="Page pagination">
109+
110+
```js
111+
strapi.entityService.findPage('api::article.article', {
80112
page: 1,
81113
pageSize: 15,
82114
});
83115
```
116+
117+
</TabItem>
118+
119+
</Tabs>
120+
121+
</TabItem>
122+
</Tabs>

0 commit comments

Comments
 (0)