Hoogle Search

Within LTS Haskell 24.41 (ghc-9.10.3)

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

  1. getPsIdName :: PersistSettings -> Text

    persistent Database.Persist.Quasi.PersistSettings.Internal

    Retrieve the default name of the id column.

  2. psIdName :: PersistSettings -> !Text

    persistent Database.Persist.Quasi.PersistSettings.Internal

    The name of the id column. Default value: id The name of the id column can also be changed on a per-model basis https://github.com/yesodweb/persistent/wiki/Persistent-entity-syntax

  3. setPsIdName :: Text -> PersistSettings -> PersistSettings

    persistent Database.Persist.Quasi.PersistSettings.Internal

    Set the default name of the id column.

  4. data BackendSpecificOverrides

    persistent Database.Persist.Sql

    Record of functions to override the default behavior in mkColumns. It is recommended you initialize this with emptyBackendSpecificOverrides and override the default values, so that as new fields are added, your code still compiles. For added safety, use the getBackendSpecific* and setBackendSpecific* functions, as a breaking change to the record field labels won't be reflected in a major version bump of the library.

  5. connectionPoolConfigIdleTimeout :: ConnectionPoolConfig -> NominalDiffTime

    persistent Database.Persist.Sql

    How long connections can remain idle before being disposed of, in seconds. Default: 600

  6. emptyBackendSpecificOverrides :: BackendSpecificOverrides

    persistent Database.Persist.Sql

    Creates an empty BackendSpecificOverrides (i.e. use the default behavior; no overrides)

  7. dbIdColumns :: SqlBackend -> EntityDef -> NonEmpty Text

    persistent Database.Persist.Sql.Util

    No documentation available.

  8. dbIdColumnsEsc :: (FieldNameDB -> Text) -> EntityDef -> NonEmpty Text

    persistent Database.Persist.Sql.Util

    No documentation available.

  9. isIdField :: PersistEntity record => EntityField record typ -> Bool

    persistent Database.Persist.Sql.Util

    No documentation available.

  10. data ImplicitIdDef

    persistent Database.Persist.TH

    A specification for how the implied ID columns are created. By default, persistent will give each table a default column named id (customizable by PersistSettings), and the column type will be whatever you'd expect from BackendKey yourBackendType. For The SqlBackend type, this is an auto incrementing integer primary key. You might want to give a different example. A common use case in postgresql is to use the UUID type, and automatically generate them using a SQL function. Previously, you'd need to add a custom Id annotation for each model.

    User
    Id   UUID default="uuid_generate_v1mc()"
    name Text
    
    Dog
    Id   UUID default="uuid_generate_v1mc()"
    name Text
    user UserId
    
    Now, you can simply create an ImplicitIdDef that corresponds to this declaration.
    newtype UUID = UUID ByteString
    
    instance PersistField UUID where
    toPersistValue (UUID bs) =
    PersistLiteral_ Escaped bs
    fromPersistValue pv =
    case pv of
    PersistLiteral_ Escaped bs ->
    Right (UUID bs)
    _ ->
    Left "nope"
    
    instance PersistFieldSql UUID where
    sqlType _ = SqlOther UUID
    
    With this instance at the ready, we can now create our implicit definition:
    uuidDef :: ImplicitIdDef
    uuidDef = mkImplicitIdDef @UUID "uuid_generate_v1mc()"
    
    And we can use setImplicitIdDef to use this with the MkPersistSettings for our block.
    mkPersist (setImplicitIdDef uuidDef sqlSettings) [persistLowerCase| ... |]
    
    TODO: either explain interaction with mkMigrate or fix it. see issue #1249 for more details.

Page 599 of many | Previous | Next