| Copyright | (c) Ole Krüger 2016 |
|---|---|
| License | BSD3 |
| Maintainer | Ole Krüger <ole@vprsm.de> |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.PostgreSQL.Store
Description
- data Errand a
- runErrand :: Connection -> Errand a -> IO (Either ErrandError a)
- execute :: Query a -> Errand Result
- execute' :: Query a -> Errand Int
- query :: Entity a => Query a -> Errand [a]
- queryWith :: Query a -> RowParser a -> Errand [a]
- insert :: TableEntity a => a -> Errand Bool
- insertMany :: TableEntity a => [a] -> Errand Int
- deleteAll :: TableEntity a => proxy a -> Errand Int
- findAll :: TableEntity a => Errand [a]
- create :: TableEntity a => proxy a -> Errand ()
- data Query a = Query {}
- pgsq :: QuasiQuoter
- castQuery :: Query a -> Query b
- class Entity a where
- class Entity a => TableEntity a where
- class Entity a => ColumnEntity a where
- data Table = Table {
- tableName :: ByteString
- tableCols :: [Column]
- data ColumnType = ColumnType {}
- data Column = Column {}
- data ErrandError
- data ErrorCode
- data ExecStatus :: *
- data RowError = RowError RowErrorLocation RowErrorDetail
- data RowErrorLocation = RowErrorLocation Column Row
- data RowErrorDetail
Errand
An interaction with the database
runErrand :: Connection -> Errand a -> IO (Either ErrandError a) Source #
Run an errand.
queryWith :: Query a -> RowParser a -> Errand [a] Source #
Execute a query and process its result set using the provided RowParser.
insertMany :: TableEntity a => [a] -> Errand Int Source #
Insert many rows into a Table.
Query
Query
Constructors
| Query | |
Fields | |
pgsq :: QuasiQuoter Source #
Generate queries conveniently. See BuildQuery to find out which types can be produced.
Entity
An entity that is used as a parameter or result of a query.
Methods
insertEntity :: a -> QueryBuilder Source #
Insert an instance of a into the query.
insertEntity :: (GenericEntity a, GEntity (AnalyzeEntity a)) => a -> QueryBuilder Source #
Insert an instance of a into the query.
parseEntity :: RowParser a Source #
Retrieve an instance of a from the result set.
parseEntity :: (GenericEntity a, GEntity (AnalyzeEntity a)) => RowParser a Source #
Retrieve an instance of a from the result set.
Instances
| Entity Bool Source # | boolean |
| Entity Double Source # | Any floating-point number |
| Entity Float Source # | Any floating-point number |
| Entity Int Source # | Any integer |
| Entity Int8 Source # | Any integer |
| Entity Int16 Source # | Any integer |
| Entity Int32 Source # | Any integer |
| Entity Int64 Source # | Any integer |
| Entity Integer Source # | Any integer |
| Entity Word Source # | Any unsigned integer |
| Entity Word8 Source # | Any unsigned integer |
| Entity Word16 Source # | Any unsigned integer |
| Entity Word32 Source # | Any unsigned integer |
| Entity Word64 Source # | Any unsigned integer |
| Entity ByteString Source # |
|
| Entity ByteString Source # |
|
| Entity Scientific Source # | Any numeric type |
| Entity String Source # |
|
| Entity Text Source # |
|
| Entity Value Source # |
|
| Entity Text Source # |
|
| Entity Natural Source # | Any unsigned integer |
| Entity TypedValue Source # | Typed column value |
| Entity Value Source # | Untyped column value |
| Entity QueryBuilder Source # | |
| Entity a => Entity (Maybe a) Source # | A value which may normally not be |
| (Entity a, Entity b) => Entity (a, b) Source # | 2 result entities in sequence |
| (Entity a, Entity b, Entity c) => Entity (a, b, c) Source # | 3 result entities in sequence |
| (Entity a, Entity b, Entity c, Entity d) => Entity (a, b, c, d) Source # | 4 result entities in sequence |
| (Entity a, Entity b, Entity c, Entity d, Entity e) => Entity (a, b, c, d, e) Source # | 5 result entities in sequence |
| (Entity a, Entity b, Entity c, Entity d, Entity e, Entity f) => Entity (a, b, c, d, e, f) Source # | 6 result entities in sequence |
| (Entity a, Entity b, Entity c, Entity d, Entity e, Entity f, Entity g) => Entity (a, b, c, d, e, f, g) Source # | 7 result entities in sequence |
Tables
class Entity a => TableEntity a where Source #
Classify a type which can be used as a table.
Methods
describeTableType :: proxy a -> Table Source #
Describe the table type.
describeTableType :: GenericTable a => proxy a -> Table Source #
Describe the table type.
class Entity a => ColumnEntity a where Source #
Classify a type which can be used as a column in a table.
Minimal complete definition
Instances
Description of a table
Constructors
| Table | |
Fields
| |
data ColumnType Source #
Description of a column type
Constructors
| ColumnType | |
Fields
| |
Desciption of a column
Constructors
| Column | |
Fields
| |
Errors
data ErrandError Source #
Error during errand
Constructors
| NoResult | No |
| UserError String | A user has thrown an error. |
| ExecError ExecStatus ErrorCode ByteString ByteString ByteString | Query execution failed. |
| ParseError RowError | Result processing failed. |
Instances
Error codes
data ExecStatus :: * #
Instances
An error that occured when parsing a row.
Constructors
| RowError RowErrorLocation RowErrorDetail |
data RowErrorDetail Source #
Errors that occur during row parsing
Constructors
| TooFewColumns | Underlying |
| ColumnRejected TypedValue | A column value could not be parsed. |
| ContentsRejected (Maybe ByteString) | The contents of a column could not be parsed. |
Instances