Node.js Ampersand模型验证混合不等待mysql查询结果

Node.js Ampersand模型验证混合不等待mysql查询结果,node.js,ampersand,ampersand.js,Node.js,Ampersand,Ampersand.js,我正在我的nodejs项目中使用ampersand模型验证mixin。 验证语法是 validations: { 'type': { type: function(){ return validateType(this._values.type); }, msg: 'type cannot be blank and it should be unique' }, validateType是一个从数据库检查其是否唯一的函数 function validateType(type) {if (_.i

我正在我的nodejs项目中使用ampersand模型验证mixin。 验证语法是

validations: { 'type': { type: function(){ return validateType(this._values.type); }, msg: 'type cannot be blank and it should be unique' },
validateType是一个从数据库检查其是否唯一的函数

function validateType(type) {if (_.isEmpty(type)) {return false;  } else {var searchData = '{"type" : "' + type + '"}';dao.searchDocument(process.env.DEVICE_CONNECTOR_TYPE_MODEL, searchData)   .then(function(resp) {if (!_.isEmpty(resp)) {return false;}else{return true;}});}}
但它不是等待结果并直接保存它

关于如何做到这一点,您有什么想法吗?

对于“后代”:目前不支持异步测试,如下所述:

因此,如果需要这种功能,您需要扩展mixin的功能