Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Database.Persist.Sql.Lifted.Expression.ArrayAggregate.PostgreSQL
Synopsis
- data AggMode
- arrayAggDistinct :: (PersistField a, PersistField [a]) => SqlExpr (Value a) -> SqlExpr (Value (Maybe [a]))
- arrayAgg :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe [a]))
- arrayAggWith :: AggMode -> SqlExpr (Value a) -> [OrderByClause] -> SqlExpr (Value (Maybe [a]))
- arrayRemove :: SqlExpr (Value [a]) -> SqlExpr (Value a) -> SqlExpr (Value [a])
- arrayRemoveNull :: SqlExpr (Value [Maybe a]) -> SqlExpr (Value [a])
- maybeArray :: (PersistField a, PersistField [a]) => SqlExpr (Value (Maybe [a])) -> SqlExpr (Value [a])
- arrayAggById :: forall val typ. (PersistEntity val, PersistField [typ], PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value [typ])
- arrayAggByIdMaybe :: forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value [typ])
- arrayAggByMaybe :: forall a b. (PersistField a, PersistField b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value b) -> SqlExpr (Value [a])
- arrayAggBy :: forall a b. (PersistField [a], PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value [a])
Documentation
Aggregate mode
Constructors
AggModeAll | ALL |
AggModeDistinct | DISTINCT |
arrayAggDistinct :: (PersistField a, PersistField [a]) => SqlExpr (Value a) -> SqlExpr (Value (Maybe [a])) #
(array_agg
) Concatenate distinct input values, including NULL
s, into
an array.
Since: esqueleto-2.5.3
arrayAggWith :: AggMode -> SqlExpr (Value a) -> [OrderByClause] -> SqlExpr (Value (Maybe [a])) #
arrayRemove :: SqlExpr (Value [a]) -> SqlExpr (Value a) -> SqlExpr (Value [a]) #
(array_remove
) Remove all elements equal to the given value from the
array.
Since: esqueleto-2.5.3
arrayRemoveNull :: SqlExpr (Value [Maybe a]) -> SqlExpr (Value [a]) #
Remove NULL
values from an array
maybeArray :: (PersistField a, PersistField [a]) => SqlExpr (Value (Maybe [a])) -> SqlExpr (Value [a]) #
Coalesce an array with an empty default value
arrayAggById :: forall val typ. (PersistEntity val, PersistField [typ], PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value [typ]) Source #
Aggregrate the given column with stable ordering (by ID)
This ensures that if you aggregrate two columns:
pure (arrayAggById
students StudentFirstName ,arrayAggById
students StudentLastName )
The list, if zipped, will be as expected.
See https://stackoverflow.com/a/7317520.
Also replaces the Maybe
result with an empty list, because really that's
what you always want.
arrayAggByIdMaybe :: forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value [typ]) Source #
arrayAggById
but for a left-outer-joined entity
If you're using (?.)
instead of (^.)
, use this instead of arrayAggById
.
arrayAggByMaybe :: forall a b. (PersistField a, PersistField b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value b) -> SqlExpr (Value [a]) Source #
arrayAggBy
but for a left-outer-joined entity
If you're using (?.)
instead of (^.)
, use this instead of arrayAggBy
.
arrayAggBy :: forall a b. (PersistField [a], PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value [a]) Source #