HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleyesod-persistent-1.6.0.8Haskell2010

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