Merge pull request #1586 from yesodweb/documentRunDB

Document runDB
This commit is contained in:
Michael Snoyman 2019-03-07 04:24:28 +02:00 committed by GitHub
commit 4b760a027e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,15 @@ type YesodDB site = ReaderT (YesodPersistBackend site) (HandlerFor site)
class Monad (YesodDB site) => YesodPersist site where
type YesodPersistBackend site
-- | 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
runDB :: YesodDB site a -> HandlerFor site a
-- | Helper for creating 'runDB'.