pg-entity-0.0.4.3: A pleasant PostgreSQL layer
Copyright© Clément Delafargue 2018
Théophile Choutri 2021
LicenseMIT
Maintainertheophile@choutri.eu
Stabilitystable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.PostgreSQL.Entity.DBT

Description

The DBT plumbing module to handle database queries and pools

Synopsis

Documentation

mkPool :: ConnectInfo -> Int -> NominalDiffTime -> Int -> IO (Pool Connection) Source #

Create a Pool Connection with the appropriate parameters

Since: 0.0.1.0

withPool :: MonadIO m => Pool Connection -> DBT IO a -> m a Source #

Run a DBT action with no explicit error handling.

This functions is suited for using MonadError error handling.

Example

Expand
let e1 = E 1 True True
result <- runExceptT @EntityError $ do
  withPool pool $ insertEntity e1
  withPool pool $ markForProcessing 1
case result of
  Left err -> print err
  Right _  -> putStrLn "Everything went well"

See the code in the example/ directory on GitHub

Since: 0.0.1.0

execute :: (ToRow params, MonadIO m) => QueryNature -> Query -> params -> DBT m Int64 Source #

Query wrapper for SQL statements which do not return.

Since: 0.0.1.0

executeMany :: (ToRow params, MonadIO m) => QueryNature -> Query -> [params] -> DBT m Int64 Source #

Query wrapper for SQL statements that operate on multiple rows which do not return.

Since: 0.0.2.0

query :: (ToRow params, FromRow result, MonadIO m) => QueryNature -> Query -> params -> DBT m (Vector result) Source #

Query wrapper that returns a Vector of results

Since: 0.0.1.0

query_ :: (FromRow result, MonadIO m) => QueryNature -> Query -> DBT m (Vector result) Source #

Query wrapper that returns a Vector of results and does not take an argument

Since: 0.0.1.0

queryOne :: (ToRow params, FromRow result, MonadIO m) => QueryNature -> Query -> params -> DBT m (Maybe result) Source #

Query wrapper that returns one result.

Since: 0.0.1.0

queryOne_ :: (FromRow result, MonadIO m) => QueryNature -> Query -> DBT m (Maybe result) Source #

Query wrapper that returns one result and does not take an argument

Since: 0.0.2.0

data QueryNature Source #

This sum type is given to the query, queryOne and execute functions to help with logging.

Since: 0.0.1.0

Constructors

Select 
Insert 
Update 
Delete 

Instances

Instances details
Show QueryNature Source # 
Instance details

Defined in Database.PostgreSQL.Entity.DBT

Eq QueryNature Source # 
Instance details

Defined in Database.PostgreSQL.Entity.DBT