Copyright | (c) Ole Krüger 2015-2016 |
---|---|
License | BSD3 |
Maintainer | Ole Krüger <ole@vprsm.de> |
Safe Haskell | None |
Language | Haskell2010 |
- data ErrandError
- data ErrorCode
- data Errand a
- runErrand :: Connection -> Errand a -> IO (Either ErrandError a)
- execute :: ErrandQuery q Result => q r -> ErrandResult q Result
- execute' :: ErrandQuery q Int => q r -> ErrandResult q Int
- query :: (Entity r, ErrandQuery q [r]) => q r -> ErrandResult q [r]
- queryWith :: (ErrandQuery q [r], KnownNat n) => RowParser n r -> q r -> ErrandResult q [r]
- prepare :: PrepQuery a r -> Errand ()
- beginTransaction :: Errand ()
- commitTransaction :: Errand ()
- saveTransaction :: ByteString -> Errand ()
- rollbackTransaction :: Errand ()
- rollbackTransactionTo :: ByteString -> Errand ()
- withTransaction :: Errand a -> Errand ()
- class ErrandQuery q r where
- type ErrandResult q r
Errand
data ErrandError Source #
Error during errand
NoResult | No |
UserError String | A user has thrown an error. |
ExecError ExecStatus ErrorCode ByteString ByteString ByteString | Query execution failed. |
ParseError RowError | Result processing failed. |
Error codes
An interaction with the database
runErrand :: Connection -> Errand a -> IO (Either ErrandError a) Source #
Run an errand.
Execute queries
execute :: ErrandQuery q Result => q r -> ErrandResult q Result Source #
Execute the query and return its internal result.
execute' :: ErrandQuery q Int => q r -> ErrandResult q Int Source #
query :: (Entity r, ErrandQuery q [r]) => q r -> ErrandResult q [r] Source #
Execute a query and process its result set.
queryWith :: (ErrandQuery q [r], KnownNat n) => RowParser n r -> q r -> ErrandResult q [r] Source #
Execute a query and process its result set using the provided RowParser
.
Prepare statements
Transactions
beginTransaction :: Errand () Source #
Begin a transaction.
commitTransaction :: Errand () Source #
Commit transaction.
saveTransaction :: ByteString -> Errand () Source #
Create savepoint within transaction.
rollbackTransaction :: Errand () Source #
Roll back transaction.
rollbackTransactionTo :: ByteString -> Errand () Source #
Roll back to a specific savepoint.
withTransaction :: Errand a -> Errand () Source #
Do something within a transaction.
Helpers
class ErrandQuery q r where Source #
Identifies q
as a query object.
type ErrandResult q r Source #
A type equal to Errand r
or a function which will eventually yield a Errand r
executeWith :: (Result -> Errand r) -> q x -> ErrandResult q r Source #
Execute the query described in q x
and pass its Result
to the given function.
ErrandQuery Query r Source # | |
ErrandQuery Statement r Source # | |
WithTuple ts => ErrandQuery (PrepQuery ts) r Source # | |