Vex · Query DSL

Logical operators (and, or, not)

and and or combine two or more conditions, not negates one, and all three nest. Each compiles to a parenthesized group, so the SQL keeps the structure of the filter. Example: bookings for Friday or Sunday, excluding bookings of one seat.

Query
{
  from: ['bookings'],
  fields: ['bookings.id', 'bookings.seats'],
  filter: {
    and: [
      {
        or: [
          { eq: ['bookings.show_night', '2026-10-23'] },
          { eq: ['bookings.show_night', '2026-10-25'] },
        ],
      },
      { not: { eq: ['bookings.seats', 1] } },
    ],
  },
}
Table
CREATE TABLE bookings (
  id text PRIMARY KEY,
  show_night text NOT NULL REFERENCES shows(night),
  member_id text NOT NULL REFERENCES members(id),
  seats integer NOT NULL
)
SQL
SELECT b1.id AS "id", b1.seats AS "seats"
FROM bookings AS b1
WHERE ((b1.show_night = '2026-10-23' OR b1.show_night = '2026-10-25') AND NOT (b1.seats = 1))
LIMIT 100
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.