joe*_*rvi 9 mysql orm node.js sequelize.js
查看您可以使用 
     的文档model.findAll({where: {attribute: x}}).但是,我想选择所有非x的属性.我在这里寻找一个正则表达式,但这似乎不是一个最佳解决方案.
做这个的最好方式是什么?
小智 12
试试这个
model.findAll({where: {attribute: { $not: 'x'}}})
Sequelize实际上为您提供了许多操作员来获取您的过滤数据.
你可以参考这里的链接
更新的方法,用于现代续集:
model.findAll({
  where: {
    someAttribute: {
      [sequelize.Op.not]: 'some value'
    }
  }
});
使用 [Op.ne] 运算符。ne 是不等于运算符。请记住从 'sequelize' 导入 { Op };
model.findAll({
      where: {
        attribute: {[Op.ne]:'x'} /*eg status: {[Op.ne]:'pending'}*/
      }
});
小智 6
请注意,它$not:'x已被弃用,并且在最新版本中不起作用。
现在我们可以使用[Op.gt:
model.findAll({
  where: {
    attribute: {[Op.not]:'x'}
  }
});
请在此处查找更多详细信息
| 归档时间: | 
 | 
| 查看次数: | 6535 次 | 
| 最近记录: |