在 Sequelize 中使用 .create(...) 方法时如何处理错误
How to Handle Errors When Using the .create(...) Method in Sequelize
嗨续集专家!
请问,使用.create(...)
方法时,如何处理错误。我在 documentation and in Whosebug 中找到了关于如何处理 .build()
和 findOrCreate()
方法错误的帖子,但没有找到 create()
方法的帖子。
非常感谢评论。
注意:
我正在使用 sequelize v3.1.0 和 tedious v1.11.0.
sequelize 中的所有异步操作 returns a promise
promise 是一个对象,其中包含一些将根据异步操作是否成功调用的方法
Model.create/findOrCreate/update/whatever.then(function () {
// Will be invoked on success
}).catch(function () {
// Will be invoked on failure
});
嗨续集专家!
请问,使用.create(...)
方法时,如何处理错误。我在 documentation and in Whosebug 中找到了关于如何处理 .build()
和 findOrCreate()
方法错误的帖子,但没有找到 create()
方法的帖子。
非常感谢评论。
注意: 我正在使用 sequelize v3.1.0 和 tedious v1.11.0.
sequelize 中的所有异步操作 returns a promise
promise 是一个对象,其中包含一些将根据异步操作是否成功调用的方法
Model.create/findOrCreate/update/whatever.then(function () {
// Will be invoked on success
}).catch(function () {
// Will be invoked on failure
});