AssertionError [ERR_ASSERTION]:在options参数中缺少where属性。顺序查找

时间:2018-06-23 15:17:41

标签: javascript sequelize.js

我正在使用findAll来进行网站的使用注册检查,但是总是收到错误消息:“ AssertionError [ERR_ASSERTION]:在options参数中缺少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;
});

}

我的续集版本4.37.10,有人可以提出建议吗?谢谢。

1 个答案:

答案 0 :(得分:0)

您不需要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;
});