使用多个或在 sequelize 中使用

Use more than one or in sequelize

我想在 sequelize using 3 or condition 中写得有点复杂 where

SQL where 示例:

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')

在sequlelize中我写了这样的东西:

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' }]?

P.S。在我使用 Op.

的项目中不用担心

你需要一个外部 $and 属性 与内部部分的条款。

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' }
            ]
        }
    ]
}