Vex · Scope policiesRow filter by role (
Row filter by role (match)
A match rule in a scope policy adds a WHERE condition on its column when a query is compiled; the query document is unchanged. Example: under the usher policy the query reads every booking, and under the member policy the same query gains member_id = $1, a condition on a column the query does not name.
{
from: ['bookings'],
fields: ['bookings.show_night', 'bookings.seats'],
sort: [{ field: 'bookings.show_night', dir: 'asc' }],
}{
usher: { read: [] },
member: {
read: [{ match: 'member_id', to: 'memberId' }],
insert: [{ set: 'member_id', to: 'memberId' }],
},
}SELECT b1.show_night AS "show_night", b1.seats AS "seats" FROM bookings AS b1 ORDER BY b1.show_night ASC LIMIT 100
SELECT b1.show_night AS "show_night", b1.seats AS "seats" FROM bookings AS b1 WHERE b1.member_id = $1 ORDER BY b1.show_night ASC LIMIT 100
[{ key: 'memberId', kind: 'scope', type: 'string' }]Runs in this page on the installed package. The input and the expected output are defined by the example.