HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Moduleyesod-persistent-1.6.0.9Haskell2010

Yesod.Persist.Core

Defines the core functionality of this package. This package is distinguished from Yesod.Persist in that the latter additionally exports the persistent modules themselves.

  • 2 types
  • 2 classes
  • 8 values
classclass Monad (YesodDB site) => YesodPersist site where
#

Associated types

Methods

  • runDB :: YesodDB site a -> HandlerFor site a

    Allows you to execute database actions within Yesod Handlers. For databases that support it, code inside the action will run as an atomic transaction.

    Example Usage
    userId <- runDB $ do
      userId <- insert $ User "username" "email@example.com"
      insert_ $ UserPreferences userId True
      pure userId
classclass YesodPersist site => YesodPersistRunner site where
#

Since 1.2.0

Methods

  • getDBRunner :: HandlerFor site (DBRunner site, HandlerFor site ())

    This function differs from runDB in that it returns a database runner function, as opposed to simply running a single action. This will usually mean that a connection is taken from a pool and then reused for each invocation. This can be useful for creating streaming responses; see runDBSource.

    It additionally returns a cleanup function to free the connection. If your code finishes successfully, you must call this cleanup to indicate changes should be committed. Otherwise, for SQL backends at least, a rollback will be used instead.

    Since 1.2.0