How can I make a conditional in a query using sequelize?

Viewed 16

I need to create a conditional in the query where if enabled = 1 or enabled = 2.

const existBusiness = await Business.findOne({
  where: { id, enabled: 1, enabled: 2 },
});

For example: if(enabled == 1 || enabled == 2)

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

const existBusiness = await Business.findOne({
    where: {
     [Op.or]: [
       {enabled: 1},
       {enabled: 2}
      ]
    }
  });

More information on Sequelize operators is available here.

Related