【问题标题】:Sequelize query with where and or operator使用 where 和 or 运算符对查询进行 Sequelize
【发布时间】:2022-11-21 03:38:55
【问题描述】:

'SELECT * FROM ng_db.public."Transactions" WHERE credited_account = 1 OR debited_account = 1;'

如何在 sequelize 中执行此查询?

我需要一个回报,向我显示有关可以出现在两列中的值的行

【问题讨论】:

    标签: typescript postgresql sequelize.js


    【解决方案1】:

    根据documentation,你应该使用[Op.or]

    你应该看看operator documentation,它真的很有用

    const { Op } = require("sequelize");
    
    YourTable.findAll({
      where: {
        [Op.or]: [
          { credited_account: 1 },
          { debited_account: 1 }
        ]
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 2015-04-28
      • 2017-08-21
      • 2019-09-28
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      相关资源
      最近更新 更多