Copyright | © 2019 Shirren Premaratne |
---|---|
License | MIT |
Maintainer | Shirren Premaratne <shirren.premaratne@gmail.com> |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Functions to generate Postgres data via the postgres-simple library.
Synopsis
- build :: ToRow q => Connection -> ParentTable -> [q] -> IO [Id]
- build1 :: ToRow q => Connection -> ParentTable -> q -> IO (Maybe Id)
- buildWith1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> [q] -> IO [Id]
- buildWith1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> [q] -> IO [Id]
- build1With1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> q -> IO (Maybe Id)
- build1With1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> q -> IO (Maybe Id)
- buildWithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> [q] -> IO [Id]
- buildWithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> [q] -> IO [Id]
- build1WithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> q -> IO (Maybe Id)
- build1WithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> q -> IO (Maybe Id)
- delete :: Connection -> Table -> IO Int64
- deleteStatement :: Table -> Query
- id' :: [Id] -> Int
- insertStatement :: ParentTable -> Query
- insertStatementWith1Rel :: ParentTable -> ChildTable -> Query
- insertStatementWith1CustomRel :: Relation -> ChildTable -> Query
- insertStatementWithManyRels :: [ParentTable] -> ChildTable -> Query
- insertStatementWithManyCustomRels :: [Relation] -> ChildTable -> Query
- mapFromIdToResult :: ParentTable -> [Id] -> [Result]
Documentation
build :: ToRow q => Connection -> ParentTable -> [q] -> IO [Id] Source #
Build a prepared statement to insert data into the database`
build1 :: ToRow q => Connection -> ParentTable -> q -> IO (Maybe Id) Source #
Similar to the build function but we only ever return a single optional result, and only take 1 value.
buildWith1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> [q] -> IO [Id] Source #
Build a prepared statement for a child table with a single foreign key to the nominated parent table.
buildWith1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> [q] -> IO [Id] Source #
Build a prepared statement for a child table with a single foreign key to the nominated parent table through a custom relation.
build1With1Rel :: ToRow q => Connection -> ParentTable -> ChildTable -> q -> IO (Maybe Id) Source #
Build a prepared statement for a child table with a single foreign key table
build1With1CustomRel :: ToRow q => Connection -> Relation -> ChildTable -> q -> IO (Maybe Id) Source #
Build a prepared statement for a child table with a single foreign key table mapped through a custom relation.
buildWithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> [q] -> IO [Id] Source #
Build a prepared statement for a child table with more than 1 parent
buildWithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> [q] -> IO [Id] Source #
Build a prepared statement for a child table with more than 1 parent mapped through a custom relation.
build1WithManyRels :: ToRow q => Connection -> [ParentTable] -> ChildTable -> q -> IO (Maybe Id) Source #
Build a prepared statement for a child table with more than 1 parent
build1WithManyCustomRels :: ToRow q => Connection -> [Relation] -> ChildTable -> q -> IO (Maybe Id) Source #
Build a prepared statement for a child table with more than 1 parent mapped through a custom relation.
delete :: Connection -> Table -> IO Int64 Source #
Perform a truncate with cascade action on the Table
deleteStatement :: Table -> Query Source #
Generate a delete statement for a table
Helper function to extract the underlying Int value from the first value in the list
insertStatement :: ParentTable -> Query Source #
Create an insert statement for a table
insertStatementWith1Rel :: ParentTable -> ChildTable -> Query Source #
Creates an insert statement for a table, and uses the parent table to also incude a foreign key in the generation of the statement.
insertStatementWith1CustomRel :: Relation -> ChildTable -> Query Source #
Creates an insert statement for a table, and uses the parent table custom relation to build an insert statement for a child table using the relation
insertStatementWithManyRels :: [ParentTable] -> ChildTable -> Query Source #
Creates an insert statement for a table, and uses multiple parent tables to also include foreign keys in the generation of the statement.
insertStatementWithManyCustomRels :: [Relation] -> ChildTable -> Query Source #
Creates an insert statement for a table where the relationship between the parent and child is modelled using a custom key.
mapFromIdToResult :: ParentTable -> [Id] -> [Result] Source #
Function to map from IO [Id] -> IO [Result]