View Source Fob.PageBreak (Fob v1.0.1)

Functions and types for operating on page break values

Link to this section Summary

Types

t()

A data structure for describing a position within an ordered data set

Functions

Compares two page breaks given the ordering defined in the queryable

Expands the n-dimensional space occupied by a bound of page-breaks

Link to this section Types

@type t() :: %Fob.PageBreak{
  column: term(),
  direction: term(),
  table: term(),
  value: term()
}

A data structure for describing a position within an ordered data set

Link to this section Functions

Link to this function

compare(a, b, query)

View Source (since 0.2.0)
@spec compare([t()], [t()], Ecto.Queryable.t()) :: :lt | :eq | :gt

Compares two page breaks given the ordering defined in the queryable

Returns :eq if the two page breaks are equal, :lt if a is would come before b in the data set when queried, and :gt if b would come before a.

Link to this function

expand_space(start, stop, proposed, query)

View Source (since 0.3.0)
@spec expand_space(start :: [t()], stop :: [t()], proposed :: [t()], Ecto.Query.t()) ::
  {new_start :: [t()], new_stop :: [t()]}

Expands the n-dimensional space occupied by a bound of page-breaks

If one holds on to the page-breaks from the start and stop of a dataset (with start being the first record returned and stop being the last record of the most recently requested page; i.e. the cursor), they have the boundaries of the page-break-space for the query. It can be useful to be able to expand this space in the case of row insertions into the database. If an insertion comes in, one must compute its page-break values and compare those to the held start and stop page-break values.

This function performs that comparison and returns a tuple of the new start and stop, where proposed could possibly replace the start or stop (or neither).