Safe Haskell | None |
---|
Model running.
- model :: AppLiftModel c s => Model c s a -> Controller c s a
- runDB :: s -> c -> Pool -> Model c s () -> IO ()
- query :: (ToRow ps, FromRow r) => [String] -> ps -> Model c s [r]
- single :: (ToRow ps, FromRow (Only r)) => [String] -> ps -> Model c s (Maybe r)
- singleNoParams :: FromRow (Only r) => [String] -> Model c s (Maybe r)
- queryNoParams :: FromRow r => [String] -> Model c s [r]
- withPoolConnection :: (MonadCatchIO m, MonadIO m) => Pool -> (Connection -> m a) -> m ()
- exec :: ToRow ps => [String] -> ps -> Model c s Int64
- newtype Only a = Only {
- fromOnly :: a
- newPool :: MonadIO m => ConnectInfo -> m Pool
- data Pool
Documentation
model :: AppLiftModel c s => Model c s a -> Controller c s aSource
Run a model action from within a controller.
single :: (ToRow ps, FromRow (Only r)) => [String] -> ps -> Model c s (Maybe r)Source
Query a single field from a single result.
singleNoParams :: FromRow (Only r) => [String] -> Model c s (Maybe r)Source
Query a single field from a single result (no params).
queryNoParams :: FromRow r => [String] -> Model c s [r]Source
Query with no parameters.
withPoolConnection :: (MonadCatchIO m, MonadIO m) => Pool -> (Connection -> m a) -> m ()Source
Use the connection pool.
exec :: ToRow ps => [String] -> ps -> Model c s Int64Source
Execute some SQL returning the rows affected.
newtype Only a
A single-value "collection".
This is useful if you need to supply a single parameter to a SQL query, or extract a single column from a SQL result.
Parameter example:
query c "select x from scores where x > ?" (Only
(42::Int))
Result example:
xs <- query_ c "select id from users"
forM_ xs $ \(Only
id) -> {- ... -}