LoginSignup
3
0

More than 5 years have passed since last update.

YesodでDBアクセスするときのトランザクション境界

Posted at

Yesod Advent Calendar 2016の16日目です。
YesodでのDB操作についての話題です。

トランザクションの境界

runDB関数でまとめた操作は同一トランザクションで実行されます。

_ <- runDB $
         insert ...
         >> insert ...
         >> update ...
         >> delete ...

ですので、runDBから複数の戻り値を返すには少し工夫が必要です。

一番簡単なのはタプルを使うことでしょう。

tuple <- runDB $ do
             retA <- selectList ...
             retB <- selectList ...
             return (retA, retB)
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0