Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data AuditGeneratorSettings = AuditGeneratorSettings {}
- data ForeignKeyType
- defaultSettings :: AuditGeneratorSettings
- generateAuditModels :: AuditGeneratorSettings -> PersistModelFile -> Text
- printForeignKey :: ForeignKeyType -> Text -> (Text, Text)
- printTopLevel :: AuditGeneratorSettings -> PersistModelFilePiece -> Text
- printEntityChild :: AuditGeneratorSettings -> EntityChild -> Text
- generateToAuditInstances :: AuditGeneratorSettings -> PersistModelFile -> Text
- printToAuditInstance :: AuditGeneratorSettings -> PersistModelFilePiece -> Text
- printModelAccessor :: AuditGeneratorSettings -> Text -> EntityChild -> Text
- printIfForeignKeyAlternate :: ForeignKeyType -> Text -> Text
- printIfForeignKeyAlternate2 :: ForeignKeyType -> Text -> EntityFieldType -> Text
- printEntityFieldTypeFunctionConnector :: EntityFieldType -> (Bool, Text)
- stringEndsInId :: String -> Bool
- firstLetterToUpperCase :: String -> String
- firstLetterToLowerCase :: String -> String
Documentation
data AuditGeneratorSettings Source
Five options for generating Audit Models and ToAudit Instances.
AuditGeneratorSettings | |
|
data ForeignKeyType Source
All foreign keys are kept in the audit models but derefenced so the original models | can be deleted without affecting the audit models. This is a work around in case the | original models and the audit models are stored in different databases. | Persist cannot handle keys across SQL and Mongo.
OriginalKey | Default setting. Link the ids as the original type with a "noreference" tag. |
MongoKeyInSQL | Store Mongo Key as a ByteString in SQL. |
SQLKeyInMongo | Store SQL Key as an Int64 in Mongo. |
defaultSettings :: AuditGeneratorSettings Source
Settings that the author assumed would be most common.
generateAuditModels :: AuditGeneratorSettings -> PersistModelFile -> Text Source
Convert a list of TopLevel
to a list of Audit Models in Text
.
printForeignKey :: ForeignKeyType -> Text -> (Text, Text) Source
printTopLevel :: AuditGeneratorSettings -> PersistModelFilePiece -> Text Source
Convert a TopLevel
to an Audit Model, white space or comment in Text
.
printEntityChild :: AuditGeneratorSettings -> EntityChild -> Text Source
Convert an EntityChild
to a piece of an Audit Model in Text
.
| It does not generate anything for EntityUnique, EntityPrimary or EntityForeign
| because Audits do not need to be unique, they will have an automatically produced Key
| and should not have any foreign keys connecting back to the original model.
generateToAuditInstances :: AuditGeneratorSettings -> PersistModelFile -> Text Source
Convert a list of TopLevel
to a to a list of ToAudit
in Text
.
printToAuditInstance :: AuditGeneratorSettings -> PersistModelFilePiece -> Text Source
Convert TopLevel
to an instance of ToAudit
in Text
.
printModelAccessor :: AuditGeneratorSettings -> Text -> EntityChild -> Text Source
Convert EntityChild
to a Model accessor.
printIfForeignKeyAlternate :: ForeignKeyType -> Text -> Text Source
Select the correct function for handling foreign keys.
stringEndsInId :: String -> Bool Source
Return true if the last two characters are Id.
firstLetterToUpperCase :: String -> String Source
Convert the first letter of a String
to the corresponding uppercase letter.
firstLetterToLowerCase :: String -> String Source
Convert the first letter of a String
to the corresponsing lowercase letter.