5
1

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.

Sequelize の transaction が commit has been called on this transaction ってなる時

Posted at

複数のDB処理を一つのトランザクションで処理するときに、あらかじめ発行しておいたSequelize.transactionを使うが、それぞれ非同期関数で処理しないと、タイトルのすでにコミットされてるよエラーになる。

Sequelizeのオートコミット機能の影響なので、configでオートコミットをオフにするか、処理を全て非同期にすればなおる。

ちなみに、forEachは awaitに対応していないので、 for文やfor of文に書き直す必要がある。

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?