[英]How can I make a conditional in a query using sequelize?
我需要在查询中创建一个条件,如果启用 = 1 或启用 = 2。
const existBusiness = await Business.findOne({
where: { id, enabled: 1, enabled: 2 },
});
例如: if(enabled == 1 || enabled == 2)
const { Op } = require("sequelize");
const existBusiness = await Business.findOne({
where: {
[Op.or]: [
{enabled: 1},
{enabled: 2}
]
}
});
有关 Sequelize 运算符的更多信息,请参见此处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.