1 {-# LANGUAGE FlexibleContexts #-}
8 import Database.Groundhog (
12 import Database.Groundhog.Core ( PersistBackend, PersistEntity )
14 import Xml ( FromXml(..) )
17 class (FromXml a, PersistEntity (Db a)) => XmlImport a where
18 -- | This is similar to the signature for Groundhog's 'insert'
19 -- function, except the 'AutoKey' we return is for our 'Db'
21 insert_xml :: (PersistBackend m) => a -> m (AutoKey (Db a))
22 insert_xml x = insert (from_xml x)
24 -- | Same rationale as 'insert_xml', except it uses 'insertByAll'.
25 insertByAll_xml :: (PersistBackend m)
27 -> m ( Either (AutoKey (Db a)) (AutoKey (Db a)) )
28 insertByAll_xml x = insertByAll (from_xml x)