'Is there a way to have multiple [op.or] in a sequelize where clause?

Is there a way to have multiple [op.or] in a sequelize where? For example lets say I want to get a user who's first name is 'John' or last name is 'john' and occupation is null or retired is true...

If I try do it like this it fails:

where: {
  [op.or]: [
    {firstName: 'John'},
    {lastName: 'John'},
  ],
  [op.or]: [
    {occupation: null},
    {retired: true},
  ],
}

I have found a work around by doing the below, but I hoping there is a better way?

where: {
  [op.or]: [
    {firstName: 'John'},
    {lastName: 'John'},
  ],
  [op.and]: [
    [op.or]: [
      {job: null},
      {retired: true},
    ],
  ],
}


Solution 1:[1]

Since you have AND operator as the main one and two OR ones then you need to indicate Op.and on the root level:

where: {
  [op.and]: [{
    [op.or]: [
      {firstName: 'John'},
      {lastName: 'John'},
    ]
  }, {
    [op.or]: [
      {job: null},
      {retired: true},
    ],
  }
  ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anatoly