[英]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.