servant-util-beam-pg-0.1.0.2: Implementation of servant-util primitives for beam-postgres.
Safe HaskellNone
LanguageHaskell2010

Servant.Util.Beam.Postgres.Sorting

Description

Converting a sorting specification to a value understandable by Beam.

Synopsis

Documentation

type SortingSpecApp backend (allParams :: [TyNamedParam Type]) = HList (SortingApp backend) allParams #

List of SortingApp functions. Describes how to apply SortingSpec params (each of possible SortingItem) to an SQL query.

Instance of this type can be created using fieldSort function. For example:

sortingSpecApp :: SortingSpecApp ["course" ?: Course, "desc" ?: Text]
sortingSpecApp =
    fieldSort "course" courseField .*.
    fieldSort "desc" descField .*.
    HNil

Annotating fieldSort call with parameter name is not mandatory but recommended to prevent possible mistakes in fieldSorts ordering.

fieldSort :: forall (name :: Symbol) a backend. (SortingBackend backend, SortedValueConstraint backend a) => SortedValue backend a -> SortingApp backend ('TyNamedParam name a) #

sortBy_ :: (backend ~ BeamSortingBackend syntax0 s0, allParams ~ AllSortingParams provided base, ApplyToSortItem backend allParams, Projectible be a, SqlOrderable be (BackendOrdering backend), ThreadRewritable (QNested s) a) => SortingSpec provided base -> (a -> SortingSpecApp backend allParams) -> Q be db (QNested s) a -> Q be db s (WithRewrittenThread (QNested s) s a) Source #

Applies orderBy_ according to the given sorting specification.