Skip to content

Configuration

David Duwaer edited this page Feb 3, 2022 · 7 revisions

Oops! Not much of this page has been written yet. However, our readme features a short version of this section. If the information is not elaborate enough, don't hesitate to create an issue notifying us about it!

Basics (required)

  • URL of the JSON-API

Pagination

Choosing between offset-based or page-based pagination

Coloquent has to translate its queries to HTTP URL strings, and in this process it has to choose between generating pagination parameters page[offset]=... and page[limit]=... (called offset-based pagination), or to generate page[]=... and page[size]=... (called page-based pagination). Bdefault, Coloquent translates to offset-based paginaion. This is determined by the static property Model.paginationStrategy, which can be overriden. I.e., to use page-based pagination, write

class YourModel extends Model
{
    static paginationStrategy = PaginationStrategy.PageBased;
}

To explicitly use offset-based pagination, write

class YourModel extends Model
{
    static paginationStrategy = PaginationStrategy.OffsetBased;
}

Overriding offset-based pagination parameter names (not released yet, see issue #23)

The default offset-based pagination parameter names are page[offset] for indicating the offset, and page[limit] for indicating the maximum number of items returned.

Overriding page-based pagination parameter names (not released yet, see issue #23)

The default page-based pagination parameter names are page[number] for indicating the page number, and page[size] for indicating the number of items on each page.