--
data InjuriesDetail =
InjuriesDetail {
+ db_xml_file_id :: Int,
db_sport :: String,
db_time_stamp :: UTCTime }
deriving (Eq, Show)
--
from_xml Message{..} =
InjuriesDetail {
+ db_xml_file_id = xml_xml_file_id,
db_sport = xml_sport,
db_time_stamp = xml_time_stamp }
-- * InjuriesDetailListing/InjuriesDetailListingXml
+-- | Database representation of an InjuriesDetailListing. It has a
+-- foreign key pointing to its parent 'InjuriesDetail', and does not
+-- contain the list of 'xml_player_listings' (which get their own
+-- table).
+--
data InjuriesDetailListing =
InjuriesDetailListing {
db_injuries_detail_id :: DefaultKey InjuriesDetail,
deriving (Eq, Show)
instance ToDb InjuriesDetailListingXml where
+ -- | The database analogue of an 'InjuriesDetailListingXml' is a
+ -- 'InjuriesDetailListing'.
type Db InjuriesDetailListingXml = InjuriesDetailListing
instance FromXmlFk InjuriesDetailListingXml where
type Parent InjuriesDetailListingXml = InjuriesDetail
+ -- | Construct a 'InjuriesDetailListing' from a
+ -- 'InjuriesDetailListingXml' and a foreign key to a
+ -- 'InjuriesDetail'.
+ --
from_xml_fk fk InjuriesDetailListingXml{..} =
InjuriesDetailListing {
db_injuries_detail_id = fk,
mkPersist tsn_codegen_config [groundhog|
- entity: InjuriesDetail
dbName: injuries_detail
+ constructors:
+ - name: InjuriesDetail
+ uniques:
+ - name: unique_injuries_detail
+ type: constraint
+ # Prevent multiple imports of the same message.
+ fields: [db_xml_file_id]
- entity: InjuriesDetailListing
dbName: injuries_detail_listings