LoginSignup
2
1

More than 5 years have passed since last update.

sequelizeを利用したNodeアプリが突然エラーを吐いたらthen問題だよ

Posted at

お伝えしたいこと

sequelize 2.1.0以降からsuccess関連が使えなくなっているので注意。大人しくthenにしましょう。

Backwards compatibility changes
Events support have been removed so using .on('success') or .success() is no longer supported. Try using .then() instead.
Trying to apply a scope that does not exist will always throw an error

こういうパターンで死にます。

User.findOne.success(function(user){ 
if (user) { 
// なんらかの処理
} else {
// なんらかの処理
});

↓こうしましょう

User.findOne.then(function(user){ 
if (user) { 
// なんらかの処理
} else {
// なんらかの処理
});
2
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
2
1