Safe Haskell | None |
---|---|
Language | Haskell98 |
A MySQL backend for persistent
.
- withMySQLPool :: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) => ConnectInfo -> Int -> (Pool backend -> m a) -> m a
- withMySQLConn :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => ConnectInfo -> (backend -> m a) -> m a
- createMySQLPool :: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) => ConnectInfo -> Int -> m (Pool backend)
- module Database.Persist.Sql
- data ConnectInfo :: * = ConnectInfo {}
- data SSLInfo :: * = SSLInfo {}
- defaultConnectInfo :: ConnectInfo
- defaultSSLInfo :: SSLInfo
- data MySQLConf = MySQLConf {}
- mockMigration :: Migration -> IO ()
- insertOnDuplicateKeyUpdate :: (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStore backend, backend ~ SqlBackend) => record -> [Update record] -> SqlPersistT m ()
- insertManyOnDuplicateKeyUpdate :: (PersistEntityBackend record ~ SqlBackend, PersistEntity record, MonadIO m) => [record] -> [SomeField record] -> [Update record] -> SqlPersistT m ()
- data SomeField record where
- SomeField :: EntityField record typ -> SomeField record
Documentation
:: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) | |
=> ConnectInfo | Connection information. |
-> Int | Number of connections to be kept open in the pool. |
-> (Pool backend -> m a) | Action to be executed that uses the connection pool. |
-> m a |
Create a MySQL connection pool and run the given action.
The pool is properly released after the action finishes using
it. Note that you should not use the given ConnectionPool
outside the action since it may be already been released.
:: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) | |
=> ConnectInfo | Connection information. |
-> (backend -> m a) | Action to be executed that uses the connection. |
-> m a |
Same as withMySQLPool
, but instead of opening a pool
of connections, only one connection is opened.
:: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) | |
=> ConnectInfo | Connection information. |
-> Int | Number of connections to be kept open in the pool. |
-> m (Pool backend) |
Create a MySQL connection pool. Note that it's your
responsibility to properly close the connection pool when
unneeded. Use withMySQLPool
for automatic resource control.
module Database.Persist.Sql
data ConnectInfo :: * #
ConnectInfo | |
|
defaultConnectInfo :: ConnectInfo #
Default information for setting up a connection.
Defaults are as follows:
- Server on
localhost
- User
root
- No password
- Database
test
- Character set
utf8
Use as in the following example:
connect defaultConnectInfo { connectHost = "db.example.com" }
Default (empty) information for setting up an SSL connection.
Information required to connect to a MySQL database
using persistent
's generic facilities. These values are the
same that are given to withMySQLPool
.
MySQLConf | |
|
mockMigration :: Migration -> IO () Source #
Mock a migration even when the database is not present. This function will mock the migration for a database even when the actual database isn't already present in the system.
insertOnDuplicateKeyUpdate :: (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStore backend, backend ~ SqlBackend) => record -> [Update record] -> SqlPersistT m () Source #
MySQL specific upsert
. This will prevent multiple queries, when one will
do.
insertManyOnDuplicateKeyUpdate Source #
:: (PersistEntityBackend record ~ SqlBackend, PersistEntity record, MonadIO m) | |
=> [record] | A list of the records you want to insert, or update |
-> [SomeField record] | A list of the fields you want to copy over. |
-> [Update record] | A list of the updates to apply that aren't dependent on the record being inserted. |
-> SqlPersistT m () |
Do a bulk insert on the given records in the first parameter. In the event that a key conflicts with a record currently in the database, the second and third parameters determine what will happen.
The second parameter is a list of fields to copy from the original value. This allows you to specify that, when a collision occurs, you'll just update the value in the database with the field values that you inserted.
The third parameter is a list of updates to perform that are independent of the value that is provided. You can use this to increment a counter value. These updates only occur if the original record is present in the database.
data SomeField record where Source #
This wraps values of an Entity's EntityField
, making them have the same
type. This allows them to be put in lists.
SomeField :: EntityField record typ -> SomeField record |