Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class Data a => Entity a where
- columnNameFor :: Entity a => a -> String -> String
- fieldTypeFor :: Entity a => a -> String -> TypeRep
- maybeFieldTypeFor :: Entity a => a -> String -> Maybe TypeRep
- toString :: Entity a => a -> String
- evidence :: forall a. Entity a => a
- evidenceFrom :: forall a. Entity a => TypeInfo a -> a
- type ResolutionCache = [(EntityId, Dynamic)]
- type EntityId = (TypeRep, SqlValue)
- data Ctx = Ctx {
- connection :: ConnWrapper
- cache :: ResolutionCache
- type GP = RIO Ctx
Documentation
class Data a => Entity a where Source #
Nothing
fromRow :: [SqlValue] -> GP a Source #
Converts a database row to a value of type a
.
toRow :: a -> GP [SqlValue] Source #
Converts a value of type a
to a database row.
idField :: a -> String Source #
Returns the name of the primary key field for a type a
.
fieldsToColumns :: a -> [(String, String)] Source #
Returns a list of tuples that map field names to column names for a type a
.
default fieldsToColumns :: a -> [(String, String)] Source #
tableName :: a -> String Source #
Returns the name of the table for a type a
.
columnNameFor :: Entity a => a -> String -> String Source #
A convenience function: returns the name of the column for a field of a type a
.
fieldTypeFor :: Entity a => a -> String -> TypeRep Source #
A convenience function: returns the TypeRep of a field of a type a
.
evidence :: forall a. Entity a => a Source #
A convenience function: returns an evidence instance of type a
.
This is useful for type inference where no instance is available.
evidenceFrom :: forall a. Entity a => TypeInfo a -> a Source #
type ResolutionCache = [(EntityId, Dynamic)] Source #
The resolution cache maps an EntityId to a Dynamic value (representing an Entity). It is used to resolve circular references during loading and storing of Entities.
type EntityId = (TypeRep, SqlValue) Source #
The EntityId is a tuple of the TypeRep and the primary key value of an Entity. It is used as a key in the resolution cache.
type Ctx defines the context in which the persistence operations are executed. It contains a connection to the database and a resolution cache for circular lookups.
Ctx | |
|