Home > database >  Sequelize query with where and or operator
Sequelize query with where and or operator

Time:11-21

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

How to do this query in sequelize?

I need a return that shows me the lines about a value that can be present in two columns

CodePudding user response:

According to the documentation, you should use [Op.or]

You should check the operator documentation, it's really usefull

const { Op } = require("sequelize");

YourTable.findAll({
  where: {
    [Op.or]: [
      { credited_account: 1 },
      { debited_account: 1 }
    ]
  }
});
  • Related