Back to Pagy

Countless

docs/toolbox/paginators/countless.md

43.5.31.3 KB
Original Source

:icon-move-to-end:  :countless


:countless is an OFFSET paginator that avoids the COUNT query, reducing the number of queries per page in half. UI helpers are working with some limitations (see Caveat).

!!!warning Consider using the :keynav_js paginator when possible! The :keynav_js offers identical UI features but utilizes the faster KEYSET pagination. !!!

=== :icon-tools:  Usage

ruby
@pagy, @records = pagy(:countless, collection, **options)
  • @pagy is the pagination instance. It provides the readers and the helpers to use in your code.
  • @records represents the eager-loaded Array of records for the page.

==- :icon-sliders:  Options

headless: true : Use this option when UI is unnecessary (e.g., for infinite scrolling) and/or to skip eager loading. In this scenario:

  • @pagy is incompatible with any helpers.
  • @records behaves like a standard collection.
  • The collection ends when @records.size < @pagy.limit.

{{ include "options/offset" }}

==- :icon-mention:  Readers

{{ include "snippets/offset-readers" }}

==- :icon-alert:  Caveat

!!!warning Nav bar links beyond the highest visited page are not known/displayed. !!!

===