This is the main CDBI-module. It provides datatypes and functions to do Database-Queries working with Entities (ER-Model)
Author: Mike Tallarek, extensions by Julia Krone, Michael Hanus
insertEntry
:: EntityDescription a -> a -> DBAction ()
Inserts an entry into the database. |
insertEntries
:: EntityDescription a -> [a] -> DBAction ()
Inserts several entries into the database. |
restoreEntries
:: EntityDescription a -> [a] -> DBAction ()
Stores entries with their current keys in the database. |
getEntries
:: Specifier -> EntityDescription a -> Criteria -> [Option] -> Maybe Int -> DBAction [a]
Gets entries from the database. |
getColumn
:: [SetOp] -> [SingleColumnSelect a] -> [Option] -> Maybe Int -> DBAction [a]
Gets a single Column from the database. |
getColumnTuple
:: [SetOp] -> [TupleColumnSelect a b] -> [Option] -> Maybe Int -> DBAction [(a,b)]
Gets two Columns from the database. |
getColumnTriple
:: [SetOp] -> [TripleColumnSelect a b c] -> [Option] -> Maybe Int -> DBAction [(a,b,c)]
Gets three Columns from the database. |
getColumnFourTuple
:: [SetOp] -> [FourColumnSelect a b c d] -> [Option] -> Maybe Int -> DBAction [(a,b,c,d)]
Gets four Columns from the database. |
getColumnFiveTuple
:: [SetOp] -> [FiveColumnSelect a b c d e] -> [Option] -> Maybe Int -> DBAction [(a,b,c,d,e)]
Gets five Columns from the database. |
getColumnSixTuple
:: [SetOp] -> [SixColumnSelect a b c d e f] -> [Option] -> Maybe Int -> DBAction [(a,b,c,d,e,f)]
Gets six Columns from the database. |
getEntriesCombined
:: Specifier -> CombinedDescription a -> [Join] -> Criteria -> [Option] -> Maybe Int -> DBAction [a]
Gets combined entries from the database. |
insertEntryCombined
:: CombinedDescription a -> a -> DBAction ()
Inserts combined entries. |
updateEntries
:: EntityDescription a -> [ColVal] -> Constraint -> DBAction ()
Updates entries depending on wether they fulfill the criteria or not |
updateEntry
:: EntityDescription a -> a -> DBAction ()
Updates an entry by ID. |
updateEntryCombined
:: CombinedDescription a -> a -> DBAction ()
Same as updateEntry but for combined Data |
deleteEntries
:: EntityDescription a -> Maybe Constraint -> DBAction ()
Deletes entries depending on wether they fulfill the criteria or not |
getAllEntries
:: EntityDescription a -> DBAction [a]
Gets all entries of an entity stored in the database. |
getCondEntries
:: EntityDescription a -> (a -> Bool) -> DBAction [a]
Gets all entries of an entity satisfying a given condition. |
getEntryWithKey
:: Show a => EntityDescription b -> Column c -> (a -> Value c) -> a -> DBAction b
Gets an entry of an entity with a given key. |
getEntriesWithColVal
:: EntityDescription a -> Column b -> Value b -> DBAction [a]
Get all entries of an entity where some column have a given value. |
insertNewEntry
:: EntityDescription a -> (a -> b -> a) -> (Int -> b) -> a -> DBAction a
Inserts a new entry of an entity and returns the new entry with the new key. |
deleteEntry
:: EntityDescription a -> Column b -> (a -> Value b) -> a -> DBAction ()
Deletes an existing entry from the database. |
deleteEntryR
:: EntityDescription a -> Column b -> Value b -> Column c -> Value c -> DBAction ()
Deletes an existing binary relation entry from the database. |
showDatabaseKey
:: String -> (a -> Int) -> a -> String
Shows a database key for an entity name as a string. |
readDatabaseKey
:: String -> (Int -> a) -> String -> Maybe a
Transforms a string into a key for an entity name. |
saveDBTerms
:: Show a => EntityDescription a -> String -> String -> IO ()
|
restoreDBTerms
:: Read a => EntityDescription a -> String -> String -> IO ()
Restores entries saved in a term file by deleting all existing entries and inserting the saved entries. |
runQueryOnDB
:: String -> DBAction a -> IO a
Executes a DB action on a database and returns the result. |
runTransactionOnDB
:: String -> DBAction a -> IO (Either DBError a)
Executes a DB action as a transcation on a database and returns the result. |
runJustTransactionOnDB
:: String -> DBAction a -> IO a
Executes a DB action as a transcation on a database and returns the result. |
Inserts an entry into the database.
|
Inserts several entries into the database.
|
Stores entries with their current keys in the database. It is an error if entries with the same key are already in the database. Thus, this operation is useful only to restore a database with saved data.
|
Gets entries from the database.
|
Gets a single Column from the database.
|
Gets two Columns from the database.
|
Gets three Columns from the database.
|
Gets four Columns from the database.
|
Gets five Columns from the database.
|
Gets six Columns from the database.
|
Gets combined entries from the database.
|
Inserts combined entries.
|
Updates entries depending on wether they fulfill the criteria or not
|
Updates an entry by ID. Works for Entities that have a primary key as first value. This operation updates the entry in the database with the ID of the entry that is given as parameter with the values of the entry given as parameter.
|
Same as updateEntry but for combined Data |
Deletes entries depending on wether they fulfill the criteria or not
|
Gets all entries of an entity stored in the database.
|
Gets all entries of an entity satisfying a given condition.
|
Gets an entry of an entity with a given key.
|
Get all entries of an entity where some column have a given value.
|
Inserts a new entry of an entity and returns the new entry with the new key.
|
Deletes an existing entry from the database.
|
Deletes an existing binary relation entry from the database.
|
Shows a database key for an entity name as a string. Useful if a textual representation of a database key is necessary, e.g., as URL parameters in web pages. This textual representation should not be used to store database keys in attributes! |
Transforms a string into a key for an entity name. Nothing is returned if the string does not represent a reasonable key. |
|
Restores entries saved in a term file by deleting all existing entries and inserting the saved entries.
|
Executes a DB action on a database and returns the result. An error is raised if the DB action produces an error.
|
Executes a DB action as a transcation on a database and returns the result. If the DB action produces an error, the transaction is rolled back and the error is returned, otherwise the transaction is committed.
|
Executes a DB action as a transcation on a database and returns the result. An error is raised if the DB action produces an error so that the transaction is rolled back.
|