Shooting Stars
Shooting Stars

Reputation: 835

Sequelize Op.or within Op.and for nested operations

I want to make the condition

(A AND B) And (C Or D Or E Or F)

When I try to do

where: {
  [Op.and]: [{
    A,
    B,
    [Op.or]: [{
        C,
        D,
        E,
        F
     }]
  }]
}

This operation will just return A And B AND C AND D AND E AND F, for some reason Op.or just fails within Op.and. Maybe there is a better way to do the logical operation, would anyone know what do?

Upvotes: 4

Views: 7701

Answers (2)

Shooting Stars
Shooting Stars

Reputation: 835

I fixed this problem by getting rid of the arrays, for some reason they were interfering in the interpretation. I guess you're not allowed to wrap Op.or with Op.and

            [Op.and]: {
                A',
                B,
                [Op.or]: {
                    C,
                    D,
                    E,
                    F
                },
            }

Upvotes: 1

Sujeet
Sujeet

Reputation: 3810

Try below,

where: {
  [Op.and]: [
    {
      A
    },
    {
      B
    },
    {
      [Op.or]: [{
        C,
        D,
        E,
        F
     }]
    }
  ]
}

See the syntax for [Op.and] here.

Upvotes: 6

Related Questions