Hoogle Search
Within LTS Haskell 24.10 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]persistent Database.Persist.TH.Internal Create data types and appropriate PersistEntity instances for the given UnboundEntityDefs. This function should be used if you are only defining a single block of Persistent models for the entire application. If you intend on defining multiple blocks in different fiels, see mkPersistWith which allows you to provide existing entity definitions so foreign key references work. Example:
mkPersist sqlSettings [persistLowerCase| User name Text age Int Dog name Text owner UserId |]
Example from a file:mkPersist sqlSettings $(persistFileWith lowerCaseSettings "models.persistentmodels")
For full information on the QuasiQuoter syntax, see Database.Persist.Quasi documentation.mkPersistSettings :: Type -> MkPersistSettingspersistent Database.Persist.TH.Internal Create an MkPersistSettings with default values.
mkPersistWith :: MkPersistSettings -> [EntityDef] -> [UnboundEntityDef] -> Q [Dec]persistent Database.Persist.TH.Internal Like mkPersist, but allows you to provide a [EntityDef] representing the predefined entities. This function will include those EntityDef when looking for foreign key references. You should use this if you intend on defining Persistent models in multiple files. Suppose we define a table Foo which has no dependencies.
module DB.Foo where mkPersistWith sqlSettings [] [persistLowerCase| Foo name Text |]
Then, we define a table Bar which depends on Foo:module DB.Bar where import DB.Foo mkPersistWith sqlSettings [entityDef (Proxy :: Proxy Foo)] [persistLowerCase| Bar fooId FooId |]
Writing out the list of EntityDef can be annoying. The $(discoverEntities) shortcut will work to reduce this boilerplate.module DB.Quux where import DB.Foo import DB.Bar mkPersistWith sqlSettings $(discoverEntities) [persistLowerCase| Quux name Text fooId FooId barId BarId |]
class
HasPersistBackend backendesqueleto Database.Esqueleto Class which allows the plucking of a BaseBackend backend from some larger type. For example, instance HasPersistBackend (SqlReadBackend, Int) where type BaseBackend (SqlReadBackend, Int) = SqlBackend persistBackend = unSqlReadBackend . fst
class HasPersistBackend backend =>
IsPersistBackend backendesqueleto Database.Esqueleto Class which witnesses that backend is essentially the same as BaseBackend backend. That is, they're isomorphic and backend is just some wrapper over BaseBackend backend.
type
SqlPersistM = SqlPersistT NoLoggingT ResourceT IOesqueleto Database.Esqueleto No documentation available.
type
SqlPersistT = ReaderT SqlBackendesqueleto Database.Esqueleto No documentation available.
fromPersistValue :: PersistField a => PersistValue -> Either Text aesqueleto Database.Esqueleto No documentation available.
fromPersistValueJSON :: FromJSON a => PersistValue -> Either Text aesqueleto Database.Esqueleto Convenience function for getting a free PersistField instance from a type with JSON instances. The JSON parser used will accept JSON values other that object and arrays. So, if your instance serializes the data to a JSON string, this will still work. Example usage in combination with toPersistValueJSON:
instance PersistField MyData where fromPersistValue = fromPersistValueJSON toPersistValue = toPersistValueJSON
fromPersistValueText :: PersistValue -> Either Text Textesqueleto Database.Esqueleto No documentation available.