Vex · API
collectQueryContext
collectQueryContext(query, schema) returns the $context keys a query requires before it can execute, each with the column its value is compared with and that column’s type. The result is derived from the query and the schema, so no separate declaration is written.
{
from: ['bookings'],
fields: ['bookings.id', 'bookings.seats'],
filter: {
and: [
{ eq: ['bookings.show_night', { $context: 'night' }] },
{ gte: ['bookings.seats', { $context: 'least' }] },
],
},
}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 )
{
night: { type: 'string', column: 'bookings.show_night' },
least: { type: 'number', column: 'bookings.seats' },
}Runs in this page on the installed package. The input and the expected output are defined by the example.