Przejdź do treści
Biblioteka skilli
Programowanie · Nauka i wyjaśnianie

pagination

/pagination

Opisuje wzorce paginacji API: offsetową, kursorową i keyset, wraz z filtrowaniem, sortowaniem i metadanymi stron, w implementacjach REST i GraphQL.

Licencja
MIT
Ostatnia zmiana repozytorium
21.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Opisuje wzorce paginacji API: offsetową, kursorową i keyset, wraz z filtrowaniem, sortowaniem i metadanymi stron, w implementacjach REST i GraphQL.

Wyzwalacze z opisu

paginationpaginatecursoroffsetpage sizenext pageinfinite scroll APIlist endpoint
Oryginalny opis (EN)

API pagination patterns. Offset-based, cursor-based, keyset pagination. Filtering, sorting, and page metadata. REST and GraphQL pagination implementations. USE WHEN: user mentions "pagination", "paginate", "cursor", "offset", "page size", "next page", "infinite scroll API", "list endpoint" DO NOT USE FOR: frontend infinite scroll UI - use frontend framework skills; database query optimization - use database skills

Jak działa

  1. Cursor-Based (recommended for large datasets)
  2. Offset-Based (simple, good for small datasets)
  3. Filtering and Sorting
  4. Spring Boot (Pageable)
  5. Comparison
  6. Anti-Patterns
  7. Production Checklist
Sekcje z nagłówków SKILL.md, w oryginale · 124 linii, 498 słów
Podgląd SKILL.md
---
name: pagination
description: |
  API pagination patterns. Offset-based, cursor-based, keyset pagination.
  Filtering, sorting, and page metadata. REST and GraphQL pagination
  implementations.

  USE WHEN: user mentions "pagination", "paginate", "cursor", "offset",
  "page size", "next page", "infinite scroll API", "list endpoint"

  DO NOT USE FOR: frontend infinite scroll UI - use frontend framework skills;
  database query optimization - use database skills
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Pagination

## Cursor-Based (recommended for large datasets)

```typescript
app.get('/api/products', async (req, res) => {
  const limit = Math.min(parseInt(req.query.limit as string) || 20, 100);
  const cursor = req.query.cursor as string | undefined;

  const where: any = {};
  if (cursor) {
    where.id = { gt: cursor };
  }

  const items = await db.product.findMany({
    where,
    take: limit + 1, // Fetch one extra to check hasMore
    orderBy: { id: 'asc' },
  });

  const hasMore = items.length > limit;
  if (hasMore) items.pop();

  res.json({
    data: items,
    pagination: {
      hasMore,
      nextCursor: hasMore ? items[items.length - 1].id : null,
    },
  });
});
```

## Offset-Based (simple, good for small datasets)

```typescript
app.get('/api/products', async (req, res) => {
  const page = Math.max(parseInt(req.query.page as string) || 1, 1);
  const limit = Math.min(parseInt(req.query.limit as string) || 20, 100);
  const offset = (page - 1) * limit;

  const [items, total] = await Promise.all([
    db.product.findMany({ skip: offset, take: limit, orderBy: { createdAt: 'desc' } }),
    db.product.count(),
  ]);

  res.json({
    data: items,
    pagination: {
      page, limit, total,
      totalPages: Math.ceil(total / limit),
      hasMore: offset + items.length < total,
    },
  });
});
```

## Filtering and Sorting

```typescript
app.get('/api/products', async (req, res) => {
  const { sort = 'createdAt', order = 'desc', category, minPrice, maxPrice, search } = req.query;

  const where: any = {};
  if (category) where.category = category;
  if (minPrice || maxPrice) {
    where.price = {};
    if (minPrice) where.price.gte = parseFloat(minPrice as string);
    if (maxPrice) where.price.lte = parseFloat(maxPrice as string);
  }
  if (search) where.name = { contains: search, mode: 'insensitive' };

  const items = await db.product.findMany({
    where,
    orderBy: { [sort as string]: order },
    take: limit,
    skip: offset,
  });

  res.json({ data: items, pagination: { /* ... */ } });
});
```

## Spring Boot (Pageable)

```java
@GetMapping("/products")
public Page<ProductDto> list(
    @RequestParam(defaultValue = "0") int page,
    @RequestParam(defaultValue = "20") int size,
    @RequestParam(defaultValue = "createdAt,desc") String[] sort) {

    Pageable pageable = PageRequest.of(page, Math.min(size, 100),
        Sort.by(Sort.Direction.fromString(sort[1]), sort[0]));
    return productRepo.findAll(pageable).map(mapper::toDto);
}
```

## Comparison

| Strategy | Pros | Cons | Best For |
|----------|------|------|----------|
| Offset | Simple, jump to page | Slow on large tables, skip drift | Admin panels, small datasets |
| Cursor | Fast, stable with inserts | Can't jump to page N | Feeds, infinite scroll, large datasets |
| Keyset | Fast, no skip drift | Complex multi-column sort | Time-series, ordered data |

## Anti-Patterns

| Anti-Pattern | Fix |
|--------------|-----|
| No max page size | Cap `limit` (e.g., max 100) |
| COUNT(*) on huge tables | Use cursor pagination, skip total count |
| Offset on millions of rows | Use cursor or keyset pagination |
| Returning all fields | Select only needed fields, support `fields` param |
| No default sorting | Always define default sort for stable results |

## Production Checklist

- [ ] Maximum page size enforced (e.g., 100)
- [ ] Default sort order defined
- [ ] Cursor pagination for large/growing datasets
- [ ] Input validation on page/limit/sort params
- [ ] Consistent response envelope (`data`, `pagination`)

Wersje

RepozytoriumWynikLicencja
Ta strona · claude-dev-suite/claude-dev-suite100MIT
thedaviddias/front-end-checklist100MIT
rshankras/claude-code-apple-skills100MIT
Esposter/Esposter90Apache-2.0

Migawka bazy z 13.11.2026 · wersja paczki d711420254b3 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100api-pagination
    Wdraża wydajną paginację API strategiami offsetową, kursorową i keyset dla dużych zbiorów danych, w tym nieskończone przewijanie.
  • 90pagination-performance
    Dzieli duże wyniki na strony o stałym koszcie przez paginację keyset z kursorem zamiast OFFSET, z ustabilnionym zakodowanym kursorem, gdy głębokie strony zwalniają lub wiersze się dublują.
  • 100api-pagination-filtering-sorting
    Projektuje stronicowanie kursorowe i offsetowe, dynamiczne filtry oraz sortowanie wielopolowe w REST API.
  • 100response-design-and-pagination
    Projektuje formaty odpowiedzi API i stronicowanie kursorowe, offsetowe lub keyset, z kopertami list i rozszerzaniem obiektów.
  • 95relay-pagination
    Opisuje paginację Relay z kursorami, nieskończonym przewijaniem, wzorcami load more i protokołami połączeń.
  • 100api-pagination-filtering-sorting
    Podaje konwencje parametrów zapytań HTTP dla paginacji, filtrowania, sortowania i wyszukiwania ze standaryzowanymi metadanymi odpowiedzi, przy endpointach list i repozytoriach zamieniających parametry na SQL.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.