-- * AutoRacingResults/Message
--- | Database representation of a 'Message'.
+-- | Database representation of a 'Message'. Comparatively, it lacks
+-- the listings and race information since they are linked via a
+-- foreign key.
--
data AutoRacingResults =
AutoRacingResults {
--- | XML Representation of an 'AutoRacingResults'.
+-- | XML Representation of an 'AutoRacingResults'. It has the same
+-- fields, but in addition contains the 'xml_listings' and
+-- 'xml_race_information'.
--
data Message =
Message {
db_nc :: Maybe Bool,
db_earnings :: Maybe Int }
+
-- | XML representation of a \<Listing\> contained within a
-- \<message\>.
--
--
type Db AutoRacingResultsListingXml = AutoRacingResultsListing
+
instance FromXmlFk AutoRacingResultsListingXml where
-- | Each 'AutoRacingResultsListingXml' is contained in (i.e. has a
-- foreign key to) a 'AutoRacingResults'.
data AutoRacingResultsRaceInformation =
AutoRacingResultsRaceInformation {
-- Note the apostrophe to disambiguate it from the
- -- AutoRacingResultsListing filed.
+ -- AutoRacingResultsListing field.
db_auto_racing_results_id' :: DefaultKey AutoRacingResults,
db_track_length :: Double,
db_track_length_kph :: Double,
reference:
onDelete: cascade
-
+# Note the apostrophe in the foreign key. This is to disambiguate
+# it from the AutoRacingResultsListing foreign key of the same name.
+# We strip it out of the dbName.
- entity: AutoRacingResultsRaceInformation
dbName: auto_racing_results_race_information
constructors:
- name: AutoRacingResultsRaceInformation
fields:
- name: db_auto_racing_results_id'
+ dbName: auto_racing_results_id
reference:
onDelete: cascade
- name: db_most_laps_leading
embeddedType:
- - {name: most_laps_leading_driver_id, dbName: most_laps_leading_driver_id}
- - {name: most_laps_leading_driver, dbName: most_laps_leading_driver}
+ - {name: most_laps_leading_driver_id,
+ dbName: most_laps_leading_driver_id}
+ - {name: most_laps_leading_driver,
+ dbName: most_laps_leading_driver}
- embedded: MostLapsLeading
fields:
--- Pickling
---
+-- | Pickler for the \<Listing\>s contained within \<message\>s.
+--
pickle_listing :: PU AutoRacingResultsListingXml
pickle_listing =
xpElem "Listing" $
-- | Pickler for the top-level 'Message'.
+--
pickle_message :: PU Message
pickle_message =
xpElem "message" $
xml_time_stamp m)
+-- | Pickler for the \<Most_Laps_Leading\> child of a
+-- \<Race_Information\>.
+--
pickle_most_laps_leading :: PU MostLapsLeading
pickle_most_laps_leading =
xpElem "Most_Laps_Leading" $
db_most_laps_leading_driver m,
db_most_laps_leading_number_of_laps m)
+
+-- | Pickler for the \<Race_Information\> child of \<message\>.
+--
pickle_race_information :: PU AutoRacingResultsRaceInformationXml
pickle_race_information =
xpElem "Race_Information" $