Hoogle Search

Within LTS Haskell 22.21 (ghc-9.6.5)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]

    persistent Database.Persist.TH

    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.

  2. mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]

    persistent-test Init

    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.

  3. mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]

    classy-prelude-yesod ClassyPrelude.Yesod

    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.

  4. mkPersist :: MkPersistSettings -> [UnboundEntityDef] -> Q [Dec]

    hledger-web Hledger.Web.Import

    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.

  5. mkPersistBackend :: IsPersistBackend backend => BaseBackend backend -> backend

    persistent Database.Persist.Class.PersistStore

    This function is how we actually construct and tag a backend as having read or write capabilities. It should be used carefully and only when actually constructing a backend. Careless use allows us to accidentally run a write query against a read-only database.

  6. mkPersistBackend :: IsPersistBackend backend => BaseBackend backend -> backend

    persistent Database.Persist.Sql.Types.Internal

    This function is how we actually construct and tag a backend as having read or write capabilities. It should be used carefully and only when actually constructing a backend. Careless use allows us to accidentally run a write query against a read-only database.

  7. mkPersistSettings :: Type -> MkPersistSettings

    persistent Database.Persist.TH

    Create an MkPersistSettings with default values.

  8. mkPersistWith :: MkPersistSettings -> [EntityDef] -> [UnboundEntityDef] -> Q [Dec]

    persistent Database.Persist.TH

    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
    |]
    

  9. mkPersistSettings :: Type -> MkPersistSettings

    classy-prelude-yesod ClassyPrelude.Yesod

    Create an MkPersistSettings with default values.

  10. mkPersistWith :: MkPersistSettings -> [EntityDef] -> [UnboundEntityDef] -> Q [Dec]

    classy-prelude-yesod ClassyPrelude.Yesod

    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
    |]
    

Page 1 of 2 | Next