3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

YesodAdvent Calendar 2016

Day 16

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?