Javascript 在sequelize中使用多个或多个
我想在sequelize中使用3或条件编写一个有点复杂的Javascript 在sequelize中使用多个或多个,javascript,node.js,database,sequelize.js,where,Javascript,Node.js,Database,Sequelize.js,Where,我想在sequelize中使用3或条件编写一个有点复杂的where SQL其中示例: where (c1 = 'a' or c2 = 'b' or c3 = 'c' or c4 = 'd') and (c5 = 'e' or c6 = 'f' or c7 = 'g' or c8 = 'h') and (c9 = 'i' or c10 = 'j') 在Sequalize中,我写了如下内容: where: { $and: { $or: [{ c1: 'a' }, { c2: 'b
where
SQL其中
示例:
where
(c1 = 'a' or c2 = 'b' or c3 = 'c' or c4 = 'd')
and (c5 = 'e' or c6 = 'f' or c7 = 'g' or c8 = 'h')
and (c9 = 'i' or c10 = 'j')
在Sequalize中,我写了如下内容:
where: {
$and: {
$or: [{ c1: 'a' }, { c2: 'b' }, { c3: 'c' }, { c4: 'd' }]
},
$or: [{ c5: 'e' }, { c6: 'f' }, { c7: 'g' }, { c8: 'h' }]
}
但是如何添加这个对象:$或:[{c9:'I'},{c10:'j'}]
注意:在我使用的项目中,不要担心,
Op
您需要一个带有内部部件条款的外部$和
属性
where: {
$and: [
{
$or: [
{ c1: 'a' }, { c2: 'b' }, { c3: 'c' }, { c4: 'd' }
]
},
{
$or: [
{ c5: 'e' }, { c6: 'f' }, { c7: 'g' }, { c8: 'h' }
]
},
{
$or: [
{ c9: 'i' }, { c10: 'j' }
]
}
]
}