Hoogle Search
Within LTS Haskell 24.32 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
(
<-. ) :: forall v typ . PersistField typ => EntityField v typ -> [typ] -> Filter vpersistent-mtl Database.Persist.Sql.Shim Check if value is in given list.
Examples
selectUsers :: MonadIO m => ReaderT SqlBackend m [Entity User] selectUsers = selectList [UserAge <-. [40, 41]] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |1 |SPJ |40 | +-----+-----+-----+ |2 |Simon|41 | +-----+-----+-----+
selectSPJ :: MonadIO m => ReaderT SqlBackend m [Entity User] selectSPJ = selectList [UserAge <-. [40]] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |1 |SPJ |40 | +-----+-----+-----+
(
<. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-mtl Database.Persist.Sql.Shim Less-than check.
Examples
selectLessAge :: MonadIO m => ReaderT SqlBackend m [Entity User] selectLessAge = selectList [UserAge <. 41 ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |1 |SPJ |40 | +-----+-----+-----+
(
<=. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-mtl Database.Persist.Sql.Shim Less-than or equal check.
Examples
selectLessEqualAge :: MonadIO m => ReaderT SqlBackend m [Entity User] selectLessEqualAge = selectList [UserAge <=. 40 ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |1 |SPJ |40 | +-----+-----+-----+
(
=. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Update vpersistent-mtl Database.Persist.Sql.Shim Assign a field a value.
Examples
updateAge :: MonadIO m => ReaderT SqlBackend m () updateAge = updateWhere [UserName ==. "SPJ" ] [UserAge =. 45]
Similar to updateWhere which is shown in the above example you can use other functions present in the module Database.Persist.Class. Note that the first parameter of updateWhere is [Filter val] and second parameter is [Update val]. By comparing this with the type of ==. and =., you can see that they match up in the above usage. The above query when applied on dataset-1, will produce this:+-----+-----+--------+ |id |name |age | +-----+-----+--------+ |1 |SPJ |40 -> 45| +-----+-----+--------+ |2 |Simon|41 | +-----+-----+--------+
(
==. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-mtl Database.Persist.Sql.Shim Check for equality.
Examples
selectSPJ :: MonadIO m => ReaderT SqlBackend m [Entity User] selectSPJ = selectList [UserName ==. "SPJ" ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |1 |SPJ |40 | +-----+-----+-----+
(
>. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-mtl Database.Persist.Sql.Shim Greater-than check.
Examples
selectGreaterAge :: MonadIO m => ReaderT SqlBackend m [Entity User] selectGreaterAge = selectList [UserAge >. 40 ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |2 |Simon|41 | +-----+-----+-----+
(
>=. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-mtl Database.Persist.Sql.Shim Greater-than or equal check.
Examples
selectGreaterEqualAge :: MonadIO m => ReaderT SqlBackend m [Entity User] selectGreaterEqualAge = selectList [UserAge >=. 41 ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |2 |Simon|41 | +-----+-----+-----+
(
||. ) :: [Filter v] -> [Filter v] -> [Filter v]persistent-mtl Database.Persist.Sql.Shim The OR of two lists of filters. For example:
selectList ([ PersonAge >. 25 , PersonAge <. 30 ] ||. [ PersonIncome >. 15000 , PersonIncome <. 25000 ]) []
will filter records where a person's age is between 25 and 30 or a person's income is between (15000 and 25000). If you are looking for an (&&.) operator to do (A AND B AND (C OR D)) you can use the (++) operator instead as there is no (&&.). For example:selectList ([ PersonAge >. 25 , PersonAge <. 30 ] ++ ([PersonCategory ==. 1] ||. [PersonCategory ==. 5])) []
will filter records where a person's age is between 25 and 30 and (person's category is either 1 or 5).(
!=. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Filter vpersistent-redis Database.Persist.Redis Non-equality check.
Examples
selectSimon :: MonadIO m => ReaderT SqlBackend m [Entity User] selectSimon = selectList [UserName !=. "SPJ" ] []
The above query when applied on dataset-1, will produce this:+-----+-----+-----+ |id |name |age | +-----+-----+-----+ |2 |Simon|41 | +-----+-----+-----+
(
*=. ) :: forall v typ . PersistField typ => EntityField v typ -> typ -> Update vpersistent-redis Database.Persist.Redis Assign a field by multiplication (*=).
Examples
multiplyAge :: MonadIO m => ReaderT SqlBackend m () multiplyAge = updateWhere [UserName ==. "SPJ" ] [UserAge *=. 2]
The above query when applied on dataset-1, will produce this:+-----+-----+--------+ |id |name |age | +-----+-----+--------+ |1 |SPJ |40 -> 80| +-----+-----+--------+ |2 |Simon|41 | +-----+-----+--------+