+
+
+
+-- | A total copy of 'XmlImport' for instances of 'FromXmlFk'.
+--
+class (Child a, FromXmlFk a, PersistEntity (Db a)) => XmlImportFk a where
+ insert_xml_fk :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> a
+ -> m (AutoKey (Db a))
+ insert_xml_fk fk x = insert $ from_xml_fk fk x
+
+ insert_xml_fk_ :: (PersistBackend m) => DefaultKey (Parent a) -> a -> m ()
+ insert_xml_fk_ fk x = insert_ $ from_xml_fk fk x
+
+ insertByAll_xml_fk :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> a
+ -> m ( Either (AutoKey (Db a)) (AutoKey (Db a)) )
+ insertByAll_xml_fk fk x = insertByAll $ from_xml_fk fk x
+
+ insert_xml_or_select_fk :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> a
+ -> m (AutoKey (Db a))
+ insert_xml_or_select_fk fk x = do
+ tmp <- insertByAll_xml_fk fk x
+ return $ (either id id) tmp
+
+
+-- | A total copy of 'XmlImport' for instances of 'FromXmlFkTeams'.
+-- This is a lot of duplicated boilerplate, but you don't have to
+-- think about it usually. What you're really worried about is that
+-- the dbimport code is understandable, and having these convenience
+-- classes makes the import much simpler since you don't have to do
+-- these conversions on-the-fly.
+--
+class (Child a,
+ FromXmlFkTeams a,
+ PersistEntity (Db a))
+ => XmlImportFkTeams a where
+ insert_xml_fk_teams :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> DefaultKey Team -- ^ Away team FK
+ -> DefaultKey Team -- ^ Home team FK
+ -> a
+ -> m (AutoKey (Db a))
+ insert_xml_fk_teams fk fk_away fk_home x =
+ insert $ from_xml_fk_teams fk fk_away fk_home x
+
+ insert_xml_fk_teams_ :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> DefaultKey Team
+ -> DefaultKey Team
+ -> a
+ -> m ()
+ insert_xml_fk_teams_ fk fk_away fk_home x =
+ insert_ $ from_xml_fk_teams fk fk_away fk_home x
+
+ insertByAll_xml_fk_teams :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> DefaultKey Team
+ -> DefaultKey Team
+ -> a
+ -> m ( Either (AutoKey (Db a)) (AutoKey (Db a)) )
+ insertByAll_xml_fk_teams fk fk_away fk_home x =
+ insertByAll $ from_xml_fk_teams fk fk_away fk_home x
+
+ insert_xml_or_select_fk_teams :: (PersistBackend m)
+ => DefaultKey (Parent a)
+ -> DefaultKey Team
+ -> DefaultKey Team
+ -> a
+ -> m (AutoKey (Db a))
+ insert_xml_or_select_fk_teams fk fk_away fk_home x = do
+ tmp <- insertByAll_xml_fk_teams fk fk_away fk_home x
+ return $ (either id id) tmp