A class that ties together a monad with a particular backend
Provided here is a low-level interface for executing commands. The 'run*'
functions are wrapped by the appropriate functions in Database.Beam.Query.
This interface is very high-level and isn't meant to expose the full power
of the underlying database. Namely, it only supports simple data retrieval
strategies. More complicated strategies (for example, Postgres's COPY)
are supported in individual backends. See the documentation of those
backends for more details.
Methods
runReturningMany :: FromBackendRow be x => BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m aRun a query determined by the given syntax, providing an action that will be called to consume the results from the database (if any). The action will get a reader action that can be used to fetch the next row. When this reader action returns Nothing, there are no rows left to consume. When the reader action returns, the database result is freed.
runNoReturn :: BeamSqlBackendSyntax be -> m ()Run the given command and don't consume any results. Useful for DML statements like INSERT, UPDATE, and DELETE, or DDL statements.
runReturningOne :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x)Run the given command and fetch the unique result. The result is Nothing if either no results are returned or more than one result is returned.
runReturningFirst :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x)Run the given command and fetch the first result. The result is Nothing if no results are returned. This is not guaranteed to automatically limit the query to one result.
runReturningList :: FromBackendRow be x => BeamSqlBackendSyntax be -> m [x]Run the given command, collect all the results, and return them as a list. May be more convenient than runReturningMany, but reads the entire result set into memory.
Instances9MonadBeam, …
MonadBeam be m => MonadBeam be (ExceptT e m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQLMonadBeam be m => MonadBeam be (ReaderT r m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQLMonadBeam be m => MonadBeam be (StateT s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQLMonadBeam be m => MonadBeam be (StateT s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQL(MonadBeam be m, Monoid s) => MonadBeam be (WriterT s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQL(MonadBeam be m, Monoid s) => MonadBeam be (WriterT s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQLMonadBeam be m => MonadBeam be (ContT r m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQL(MonadBeam be m, Monoid w) => MonadBeam be (RWST r w s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQL(MonadBeam be m, Monoid w) => MonadBeam be (RWST r w s m)Defined in beam-core-0.11.1.0 · Database.Beam.Backend.SQL