#"and" and "or" order in where makes a difference

1 messages · Page 1 of 1 (latest)

hollow hound
#

The first condition is always overriden with the second condition.

      or: [
        {
          approved: {
            equals: true,
          },
        },
        ...(user
          ? [
              {
                user: {
                  equals: user.id,
                },
              },
            ]
          : []),
      ],
      and: conditions,

Ok apparently there can only be one top level condition.
This works:

      and: [
        ...conditions,
        {
          or: [
            {
              approved: {
                equals: true,
              },
            },
            ...(user
              ? [
                  {
                    user: {
                      equals: user.id,
                    },
                  },
                ]
              : []),
          ],
        },
      ],