我在 sequelize 中使用 findAll 进行网站的使用注册检查,但总是收到错误消息:“AssertionError [ERR_ASSERTION]: 缺少选项参数中的 where 属性”。我的代码非常简单,如下所示:
var checkRegister = function (data, callback){
userModel.findAll({
'where': {
'$and': [
{'phoneNumber' : data.phoneNumber},
{'password' :
{$ne : null }
}
]
}
}).then(callback).catch(function(e) {
console.log('find user error,', e);
throw e;
});
}
我的 Sequelize 版本 4.37.10,有人能给点建议吗?提前致谢。
最佳答案
您不需要 where
中的引号,也可以不用 and
。像这样的东西
var checkRegister = function (data, callback){
userModel.findAll({
where: {
phoneNumber: data.phoneNumber,
password: { [Op.ne]: null }
}
}).then(callback).catch(function(e) {
console.log('find user error,', e);
throw e;
});
关于javascript - 断言错误 [ERR_ASSERTION] : Missing where attribute in the options parameter. Sequelize findALL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51002497/