0

Hi sequelize experts!

I would like to ask, how to handle errors when using the method .create(...). I found posts both in the documentation and in stackoverflow on how to handle errors for the .build() and findOrCreate() methods but not for the create() method.

Comments are highly appreciated.

Note: I am using sequelize v3.1.0 and tedious v1.11.0.

Community
  • 1
  • 1
leonard.javiniar
  • 539
  • 8
  • 25

1 Answers1

0

All async actions in sequelize returns a promise

A promise is an object with some mehods that will be invoked, based on whether the async action succeeded or not

Model.create/findOrCreate/update/whatever.then(function () {
  // Will be invoked on success
}).catch(function () {
  // Will be invoked on failure
});
Jan Aagaard Meier
  • 28,078
  • 8
  • 95
  • 66