Skip to content

Commit

Permalink
Improve the keyset docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Sep 28, 2024
1 parent 83f877c commit bfa28f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions docs/api/keyset.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ less convenient for UIs.
| `uniquely ordered` | When the concatenation of the values of the ordered columns is unique for each record. It is similar to a composite primary `key` for the ordered table, but dynamically based on the `keyset` columns. |
| `set` | The `uniquely ordered` `ActiveRecord::Relation` or `Sequel::Dataset` collection to paginate. |
| `keyset` | The hash of column/direction pairs. Pagy extracts it from the order of the `set`. |
| `latest` | The hash of `keyset` attributes of the `latest` fetched record (from the latest page). Pagy decodes it from the `:page` variable, and uses it to filter out the records already fetched. |
| `latest` | The hash of `keyset` attributes of the `latest` fetched record (from the latest page). Pagy decodes it from the `:page` variable and uses it to filter out the records already fetched. |
| `next` | The next `page`, i.e. the encoded reference to the last record of the **current page**. |
| `page` | The current `page`, i.e. the encoded reference to the `latest` record of the **latest page**. |

Expand Down Expand Up @@ -162,10 +162,9 @@ automatically assigned from the `limit` request param.

=== `:tuple_comparison`

Boolean variable that enables the tuple comparison e.g. `(brand, id) > (:brand, :id)`. It works only for same direction order,
hence it's ignored for mixed order. Check how your DB supports it (your `keyset` should include only `NOT NULL` columns).
Default
`nil`.
Boolean variable that enables the tuple comparison e.g. `(brand, id) > (:brand, :id)`. It works only with the same direction
order, hence it's ignored for mixed order. Check how your DB supports it (your `keyset` should include only `NOT NULL` columns).
Default `nil`.

==- `:after_latest`

Expand Down Expand Up @@ -242,7 +241,7 @@ They may have been stored as strings formatted differently than the default form
- Ensure that the composite index reflects exactly the columns sequence and order of your keyset
- Research about your specific DB features, type of index and performance for different ordering. Use SQL `EXPLAIN ANALYZE`
or similar tool to confirm.
- Consider using the same direction order, enabling the `:tuple_comparison`, changing type of index (different DBs may behave
- Consider using the same direction order, enabling the `:tuple_comparison`, and changing type of index (different DBs may behave
differently)
- Consider using your custom optimized `when` query with the [:after_latest](#after-latest) variable
!!!
Expand Down
4 changes: 2 additions & 2 deletions docs/extras/keyset.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ categories:

# Keyset Extra

Paginate with the Pagy keyset pagination technique.
Paginate with the Pagy keyset pagination technique.

[!button corners="pill" variant="success" text=":icon-play: Try it now!"](/playground.md#3-demo-app)
[!button corners="pill" variant="success" text=":icon-play: Try it now!"](/playground.md#5-keyset-apps)

## Overview

Expand Down

0 comments on commit bfa28f5

Please sign in to comment.