DataProvider.Pagination (DataProvider v1.0.0) View Source

Module, which implements business logic of separation data by pages in DataProvider.

Link to this section Summary

Functions

Creates new DataProvider.Pagination struct with received params.

Calculates end position for received pagination.

Returns current page value of DataProvider by DataProvider.Pagination

Returns size of page in current DataProvider.Pagination of DataProvider

Changes the value of field page

Changes the value of field page_size

Returns count of items, which gonna be put load into DataProvider.Data

Calculates starting position for received pagination.

Link to this section Types

Specs

t() :: %DataProvider.Pagination{page: integer(), page_size: integer()}

Schema of DataProvider.Pagination.

Contains:

  • page - Current page of dataprovider.

  • page_size - count of items in one page of data provider.

Link to this section Functions

Specs

create(map()) :: t()

Creates new DataProvider.Pagination struct with received params.

By default, fields will be:

  • page - @default_page

  • page_size - @default_page_size

Link to this function

end_position(pagination)

View Source

Specs

end_position(t()) :: integer()

Calculates end position for received pagination.

Requires for calculating selection limit in list of data.

Specs

page(t()) :: integer()

Returns current page value of DataProvider by DataProvider.Pagination

Specs

page_size(t()) :: integer()

Returns size of page in current DataProvider.Pagination of DataProvider

Link to this function

put_page(pagination, page)

View Source

Specs

put_page(t(), integer()) :: t()

Changes the value of field page

Link to this function

put_page_size(pagination, page_size)

View Source

Specs

put_page_size(t(), integer()) :: t()

Changes the value of field page_size

Link to this function

selection_limit(pagination)

View Source

Specs

selection_limit(t()) :: integer()

Returns count of items, which gonna be put load into DataProvider.Data

Link to this function

start_position(pagination)

View Source

Specs

start_position(t()) :: integer()

Calculates starting position for received pagination.

Requires for calculating start position in list of data or offset in query condition