persistent-audit-0.1.0.3: Parses a Persist Model file and produces Audit Models

Safe HaskellNone
LanguageHaskell2010

Database.Persist.Audit.Class

Synopsis

Documentation

class ToAudit a where Source #

Persistent Model types that have a corresponding Audit type as produced by generateAuditModels need to implement ToAudit in order to use the queries from Queries. Given the following two Persistent models:

Person
  name String
  age Int Maybe

PersonAudit
  name String
  age Int Maybe
  originalId PersonId noreference
  auditAction AuditAction
  editedBy Text
  editedOn UTCTime

The ToAudit instance should look like this:

instance ToAudit Person where
 type AuditResult Person = PersonAudit
 toAudit v k auditAction editedBy editedOn = PersonAudit (personName v)
                                                         (personAge v)
                                                         k auditAction editedBy editedOn 

generateAuditModels can help automate these instances.

Minimal complete definition

toAudit

Associated Types

type AuditResult a :: * Source #

Methods

toAudit :: a -> Key a -> AuditAction -> Text -> UTCTime -> AuditResult a Source #