Skip to content

docs: add pagination and limit: 0 information in pagination for API docs #12243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/queries/pagination.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ All collection `find` queries are paginated automatically. Responses are returne

All Payload APIs support the pagination controls below. With them, you can create paginated lists of documents within your application:

| Control | Description |
| ------- | --------------------------------------- |
| `limit` | Limits the number of documents returned |
| `page` | Get a specific page number |
| Control | Default | Description |
| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `limit` | `10` | Limits the number of documents returned per page - set to `0` to show all documents, we recommend `pagination: false` alongside with this in order to improve performance of returning all documents |
| `pagination` | `true` | Set to `false` to disable pagination and return all documents |
| `page` | `1` | Get a specific page number |

### Disabling pagination within Local API

For `find` operations within the Local API, you can disable pagination to retrieve all documents from a collection by passing `pagination: false` to the `find` local operation.

### Difference between `limit: 0` and `pagination: false`

While you may get the same results when passing just `limit: 0`, the actual logic of pagination is separate and is still being run unless you use `pagination: false`, instead you just get all the results on page 1.

For optimization, we recommend using `limit: 0` with `pagination: false` to avoid running the pagination logic. This is especially important when using `find` with a large number of documents, as it can significantly improve performance.