vault backup: 2026-05-15 16:33:15

This commit is contained in:
Vadym Samoilenko 2026-05-15 16:33:15 +01:00
parent 1fc532f636
commit 02cc5afbbf
5 changed files with 105 additions and 1 deletions

View file

@ -85,3 +85,4 @@ tags: [daily]
- 16:29 (1min) — session ended | `ai_leed`
- 16:30 — session ended | `ai_leed`
- 16:31 — session ended | `ai_leed`
- 16:33 — session ended | `ai_leed`

View file

@ -35,7 +35,7 @@ This 3-hop pattern works for hundreds of articles without vector search.
| [[wiki/reports/_index\|reports/]] | Weekly and monthly summaries — generate: `uv run python scripts/report-generator.py --weekly` | 1 |
| [[wiki/infrastructure/_index\|infrastructure/]] | Server inventory: all 10 SSH hosts — optical, optical-dev, optical-prod, baic, librechat, modocmms, box-cli, aimpress, pve | 12 |
| [[wiki/testing/_index\|testing/]] | Web app testing: functional, performance, security, UI types; TDD/BDD/Agile methodologies; Selenium/Cypress/Playwright/JMeter/OWASP ZAP tools | 1 |
| [[wiki/payloadcms/_index\|payloadcms/]] | Full Payload CMS reference — getting started, config, database (Postgres/MongoDB/SQLite), all 22 field types, access control, hooks, authentication (cookies, JWT, API keys, custom strategies, token data), admin UI, custom components, Lexical rich text, live preview, versions/drafts, Local/REST/GraphQL APIs, queries, plugins, jobs queue, upload, ecommerce, production deploy, TypeScript, migration guides, i18n, localization, hierarchy | 126 |
| [[wiki/payloadcms/_index\|payloadcms/]] | Full Payload CMS reference — getting started, config, database (Postgres/MongoDB/SQLite), all 22 field types, access control, hooks, authentication (cookies, JWT, API keys, custom strategies, token data), admin UI, custom components, Lexical rich text, live preview, versions/drafts, Local/REST/GraphQL APIs, queries, plugins, jobs queue, upload, ecommerce, production deploy, TypeScript, migration guides, i18n, localization, hierarchy | 127 |
| [[wiki/shared-patterns/_index\|shared-patterns/]] | Oliver Agency standard library patterns: httpx, structlog, pydantic-settings, alembic — reuse before writing from scratch | 4 |
| [[wiki/mistakes/_index\|mistakes/]] | Anti-patterns extracted from sessions — per-stack running lists (fastapi, react, docker, postgres, general) — injected at session start | 5 |

View file

@ -127,3 +127,4 @@
| [[wiki/payloadcms/building-without-db-connection\|Building Without a DB Connection]] | Docker build fails when Next.js SSG calls Local API — two-phase `compile`/`generate` build modes, `force-dynamic` escape hatch, `NEXT_PUBLIC_` gotcha | raw/production__building-without-a-db-connection.md | 2026-05-15 |
| [[wiki/payloadcms/production-preventing-abuse\|Production — Preventing API Abuse]] | Login rate limiting (maxLoginAttempts/lockTime), maxDepth, CSRF, CORS, GraphQL complexity limits, malicious file upload mitigation | raw/production__preventing-abuse.md | 2026-05-15 |
| [[wiki/payloadcms/queries-depth\|Queries — Depth (Relationship Population)]] | depth=0 (IDs only) vs depth=N (full objects), defaultDepth config, field-level maxDepth cap, performance notes, GraphQL exception | raw/queries__depth.md | 2026-05-15 |
| [[wiki/payloadcms/queries-pagination\|Queries — Pagination]] | Default pagination (limit/page/pagination options), response shape (docs + metadata), limit:1 perf tip, disabling pagination for bulk ops | raw/queries__pagination.md | 2026-05-15 |

View file

@ -0,0 +1,102 @@
---
title: "Queries — Pagination"
aliases: [payload-pagination, payload-find-pagination]
tags: [payloadcms, queries, pagination, rest-api, local-api]
sources: [raw/queries__pagination.md]
created: 2026-05-15
updated: 2026-05-15
---
## Overview
All Payload `find` operations are **paginated by default**. Responses wrap documents in a `docs` array alongside pagination metadata.
## Options
| Option | Default | Description |
|--------|---------|-------------|
| `limit` | `10` | Max documents returned per page |
| `page` | `1` | Which page to fetch |
| `pagination` | `true` | Set `false` to disable and return all docs |
> `limit: 0` automatically disables pagination (same as `pagination: false`).
## Local API
```ts
const posts = await payload.find({
collection: 'posts',
limit: 10,
page: 2,
})
```
## REST API
```
GET /api/posts?limit=10&page=2
```
## Response Shape
```json
{
"docs": [...],
"totalDocs": 6,
"limit": 10,
"totalPages": 1,
"page": 1,
"pagingCounter": 1,
"hasPrevPage": false,
"hasNextPage": false,
"prevPage": null,
"nextPage": null
}
```
| Field | Description |
|-------|-------------|
| `docs` | Array of documents for the current page |
| `totalDocs` | Total documents in the collection matching the query |
| `totalPages` | Total pages at the current `limit` |
| `pagingCounter` | Index of the first doc on this page |
| `hasPrevPage` / `hasNextPage` | Boolean navigation flags |
| `prevPage` / `nextPage` | Page numbers or `null` |
## Performance Tips
### Limit to 1 when querying by unique field
```ts
await payload.find({
collection: 'posts',
where: { slug: { equals: 'my-post' } },
limit: 1, // no need to scan further
})
```
### Disable pagination for bulk operations
```ts
const all = await payload.find({
collection: 'posts',
pagination: false, // skips COUNT query overhead
})
```
Disabling pagination removes the `COUNT(*)` overhead — useful for migrations, exports, or scheduled jobs processing all documents.
## Key Takeaways
- All `find` queries return paginated results by default (`limit: 10`, `page: 1`)
- Response always has `docs[]` + metadata fields (`totalDocs`, `totalPages`, `hasNextPage`, etc.)
- Set `limit: 1` when querying by unique field (slug, email) for a fast DB lookup
- Set `pagination: false` (or `limit: 0`) to retrieve all documents in one call — avoids COUNT overhead
- Works identically across Local API, REST, and GraphQL (GraphQL has its own pagination shape)
## Related
- [[wiki/payloadcms/queries|Queries — Overview]] — where operators, sort, select, depth
- [[wiki/payloadcms/queries-depth|Queries — Depth]] — relationship population depth
- [[wiki/payloadcms/rest-api|REST API]] — full query param reference
- [[wiki/payloadcms/local-api|Local API]] — direct DB access patterns