Safe Haskell | None |
---|
Database.Persist.Query.GenericSql
- class PersistStore backend m => PersistQuery backend m where
- update :: PersistEntity val => Key backend val -> [Update val] -> backend m ()
- updateGet :: PersistEntity val => Key backend val -> [Update val] -> backend m val
- updateWhere :: PersistEntity val => [Filter val] -> [Update val] -> backend m ()
- deleteWhere :: PersistEntity val => [Filter val] -> backend m ()
- selectSource :: (PersistEntity val, PersistEntityBackend val ~ backend) => [Filter val] -> [SelectOpt val] -> Source (ResourceT (backend m)) (Entity val)
- selectFirst :: (PersistEntity val, PersistEntityBackend val ~ backend) => [Filter val] -> [SelectOpt val] -> backend m (Maybe (Entity val))
- selectKeys :: PersistEntity val => [Filter val] -> [SelectOpt val] -> Source (ResourceT (backend m)) (Key backend val)
- count :: PersistEntity val => [Filter val] -> backend m Int
- newtype SqlPersist m a = SqlPersist {
- unSqlPersist :: ReaderT Connection m a
- filterClauseNoWhere :: PersistEntity val => Bool -> Connection -> [Filter val] -> Text
- filterClauseNoWhereOrNull :: PersistEntity val => Bool -> Connection -> [Filter val] -> Text
- getFiltsValues :: forall val. PersistEntity val => Connection -> [Filter val] -> [PersistValue]
- selectSourceConn :: (PersistEntity val, SqlPersist ~ PersistEntityBackend val, MonadThrow m, MonadUnsafeIO m, MonadIO m, MonadBaseControl IO m, MonadLogger m) => Connection -> [Filter val] -> [SelectOpt val] -> Source (ResourceT m) (Entity val)
- dummyFromFilts :: [Filter v] -> v
- orderClause :: PersistEntity val => Bool -> Connection -> SelectOpt val -> Text
Documentation
class PersistStore backend m => PersistQuery backend m whereSource
Methods
update :: PersistEntity val => Key backend val -> [Update val] -> backend m ()Source
Update individual fields on a specific record.
updateGet :: PersistEntity val => Key backend val -> [Update val] -> backend m valSource
Update individual fields on a specific record, and retrieve the updated value from the database.
Note that this function will throw an exception if the given key is not found in the database.
updateWhere :: PersistEntity val => [Filter val] -> [Update val] -> backend m ()Source
Update individual fields on any record matching the given criterion.
deleteWhere :: PersistEntity val => [Filter val] -> backend m ()Source
Delete all records matching the given criterion.
selectSource :: (PersistEntity val, PersistEntityBackend val ~ backend) => [Filter val] -> [SelectOpt val] -> Source (ResourceT (backend m)) (Entity val)Source
Get all records matching the given criterion in the specified order. Returns also the identifiers.
selectFirst :: (PersistEntity val, PersistEntityBackend val ~ backend) => [Filter val] -> [SelectOpt val] -> backend m (Maybe (Entity val))Source
get just the first record for the criterion
selectKeys :: PersistEntity val => [Filter val] -> [SelectOpt val] -> Source (ResourceT (backend m)) (Key backend val)Source
Get the Key
s of all records matching the given criterion.
count :: PersistEntity val => [Filter val] -> backend m IntSource
The total number of records fulfilling the given criterion.
Instances
(PersistStore SqlPersist m, MonadThrow m, MonadIO m, MonadUnsafeIO m, MonadBaseControl IO m, MonadLogger m) => PersistQuery SqlPersist m |
newtype SqlPersist m a Source
Constructors
SqlPersist | |
Fields
|
Instances
Arguments
:: PersistEntity val | |
=> Bool | include table name? |
-> Connection | |
-> [Filter val] | |
-> Text |
filterClauseNoWhereOrNullSource
Arguments
:: PersistEntity val | |
=> Bool | include table name? |
-> Connection | |
-> [Filter val] | |
-> Text |
getFiltsValues :: forall val. PersistEntity val => Connection -> [Filter val] -> [PersistValue]Source
selectSourceConn :: (PersistEntity val, SqlPersist ~ PersistEntityBackend val, MonadThrow m, MonadUnsafeIO m, MonadIO m, MonadBaseControl IO m, MonadLogger m) => Connection -> [Filter val] -> [SelectOpt val] -> Source (ResourceT m) (Entity val)Source
Equivalent to selectSource
, but instead of getting the connection from
the environment inside a SqlPersist
monad, provide an explicit
Connection
. This can allow you to use the returned Source
in an
arbitrary monad.
dummyFromFilts :: [Filter v] -> vSource
Arguments
:: PersistEntity val | |
=> Bool | include the table name |
-> Connection | |
-> SelectOpt val | |
-> Text |