> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gobetter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Cursor-Based Pagination

> Database query design patterns for consistent, leak-free pagination

This codebase uses **cursor-based pagination**. Do not use offset-based pagination.

Use a stable cursor such as:

* `id`
* `createdAt`
* `updatedAt`

Prefer `createdAt` or `updatedAt` for chronological pagination.

```ts theme={null}
.where(lt(table.createdAt, new Date(lastCreatedAt)))
.orderBy(desc(table.createdAt))
.limit(20)
```

Avoid `.offset()` for pagination.
