Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
An implementation of the DBLayer which uses Persistent and SQLite.
Synopsis
- newDBLayer :: Tracer IO PoolDbLog -> TimeInterpreter IO -> SqliteContext -> DBLayer IO
- withDBLayer :: Tracer IO PoolDbLog -> Maybe FilePath -> TimeInterpreter IO -> ( DBLayer IO -> IO a) -> IO a
- withDecoratedDBLayer :: DBDecorator IO -> Tracer IO PoolDbLog -> Maybe FilePath -> TimeInterpreter IO -> ( DBLayer IO -> IO a) -> IO a
-
newtype
DBDecorator
a =
DBDecorator
{
- decorateDBLayer :: DBLayer a -> DBLayer a
- undecoratedDB :: DBDecorator a
- defaultFilePath :: FilePath -> FilePath
- data DatabaseView = DatabaseView { }
- createViews :: [ ManualMigration ]
Documentation
:: Tracer IO PoolDbLog |
Logging object |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> SqliteContext |
A (thread-) safe wrapper for running db queries. |
-> DBLayer IO |
Sets up a connection to the SQLite database.
Database migrations are run to create tables if necessary.
If the given file path does not exist, it will be created by the sqlite library.
getDBLayer
will provide the actual
DBLayer
implementation. The database
should be closed with
destroyDBLayer
. If you use
withDBLayer
then both of
these things will be handled for you.
:: Tracer IO PoolDbLog |
Logging object. |
-> Maybe FilePath |
Database file location, or
|
-> TimeInterpreter IO |
The time interpreter object. |
-> ( DBLayer IO -> IO a) |
Action to run. |
-> IO a |
Runs an action with a connection to the SQLite database.
Database migrations are run to create tables if necessary.
If the given file path does not exist, it will be created by the sqlite library.
:: DBDecorator IO |
The database decorator. |
-> Tracer IO PoolDbLog |
Logging object |
-> Maybe FilePath |
Database file location, or Nothing for in-memory database |
-> TimeInterpreter IO |
The time interpreter object. |
-> ( DBLayer IO -> IO a) |
Action to run. |
-> IO a |
Runs an action with a connection to the SQLite database.
This function has the same behaviour as
withDBLayer
, but provides a way
to decorate the created
DBLayer
object with a
DBDecorator
, useful for
instrumenting or monitoring calls to database operations.
newtype DBDecorator a Source #
A decorator for the database layer, useful for instrumenting or monitoring calls to database operations.
DBDecorator | |
|
undecoratedDB :: DBDecorator a Source #
The identity decorator.
Equivalent to an undecorated database.
Return the preferred
FilePath
for the stake pool .sqlite file, given a
parent directory.
data DatabaseView Source #
Represents a database view.
DatabaseView | |
|
createViews :: [ ManualMigration ] Source #