Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implements filtering with beam-postgres.
When setting filtering for an endpoint, you usually need to construct a filtering spec application first, which describes how to perform filtering over your rows:
filteringSpecApp
:: FilteringSpecApp
(QExprFilterBackend syntax s)
[ "course" ?: 'AutoFilter Course
, "desc" ?: 'AutoFilter Text
, "isAwesome" ?: 'ManualFilter Bool
]
filteringSpecApp =
filterOn_ "course" courseField .*.
filterOn_
"desc" descField .*.
customFilter_ @"isAwesome"
(isAwesome -> (courseAwesomeness >. val_ 42) ==. val_ isAwesome) .*.
HNil
Annotating filterOn
and customFilter
calls with parameter name is fully optional
and used only to visually disambiguate filters of the same types.
Next, you use matches_
or filterGuard_
to build a filtering expression understandable
by Beam.
Synopsis
- matches_ :: (BeamSqlBackend be, backend ~ QExprFilterBackend be s, BackendApplySomeFilter backend params) => FilteringSpec params -> FilteringSpecApp backend params -> QExpr be s Bool
- filtersGuard_ :: (backend ~ QFilterBackend be db s, BackendApplySomeFilter backend params) => FilteringSpec params -> FilteringSpecApp backend params -> Q be db s ()
- filterOn :: forall k (name :: Symbol) (backend :: k) a. Typeable a => AutoFilteredValue backend a -> FilteringApp backend ('TyNamedParam name ('AutoFilter a))
- manualFilter :: forall k (name :: Symbol) (backend :: k) a. Typeable a => (a -> MatchPredicate backend) -> FilteringApp backend ('TyNamedParam name ('ManualFilter a))
- likeToSqlPattern :: LikePattern -> String
Documentation
matches_ :: (BeamSqlBackend be, backend ~ QExprFilterBackend be s, BackendApplySomeFilter backend params) => FilteringSpec params -> FilteringSpecApp backend params -> QExpr be s Bool Source #
Applies a whole filtering specification to a set of response fields.
Resulting value can be put to guard_
or filter_
function.
filtersGuard_ :: (backend ~ QFilterBackend be db s, BackendApplySomeFilter backend params) => FilteringSpec params -> FilteringSpecApp backend params -> Q be db s () Source #
Applies a whole filtering specification to a set of response fields.
Resulting value can be monadically binded with the remaining query (just like guard_
).
filterOn :: forall k (name :: Symbol) (backend :: k) a. Typeable a => AutoFilteredValue backend a -> FilteringApp backend ('TyNamedParam name ('AutoFilter a)) #
Implement an automatic filter. User-provided filtering operation will do filter on this value.
manualFilter :: forall k (name :: Symbol) (backend :: k) a. Typeable a => (a -> MatchPredicate backend) -> FilteringApp backend ('TyNamedParam name ('ManualFilter a)) #
Implement a manual filter. You are provided with a value which user supplied and so you have to construct a Beam predicate involving that value and relevant response fields.
Internals
likeToSqlPattern :: LikePattern -> String Source #