是否可以使用 Sequelize.js 进行异步验证器?我想在保存模型之前检查是否存在关联。像这样的东西:
User = db.define("user", {
name: Sequelize.STRING
},
{
validate:
hasDevice: ->
@getDevices().success (devices) ->
throw Exception if (devices.length < 1)
return
})
# .... Device is just another model
User.hasMany(Device)
或者有没有办法强制检查同步运行?(不理想)