为什么Op.not运算符不再在Sequelize 4.41.0中工作?

时间:2018-11-30 15:59:59

标签: node.js sequelize.js where operator-keyword not-operator

我最近升级了项目中的许多软件包,由于这样做,因此以下查询现在失败:

query['where'] = { [Op.and]: [
        sequelize.where(Database.getInstance().getConnection().col('id'), '!=', jsonObject['id'] ),
        sequelize.where(Database.getInstance().getConnection().col('username'), jsonObject['username'])
]};
console.log('Check if username is unique...');
console.log(query);

结果为:

 Unhandled rejection Error: Invalid value Where {
   attribute: Col { col: 'id' },
   comparator: '=',
   logic: { [Symbol(not)]: 1563 } }
   attribute: Col { col: 'id' },

我也尝试过:

query['where'] = { [Op.and]: [
    sequelize.where(Database.getInstance().getConnection().col('id'), '!=', jsonObject['id'] ),
    sequelize.where(Database.getInstance().getConnection().col('username'), jsonObject['username'])
]};

While following the docs,但仍然导致错误:

Unhandled rejection Error: Invalid value Where { attribute: Col { col: 'id' }, comparator: '!=', logic: 1563 }

0 个答案:

没有答案