Write table policies
Rules that decide which rows each person can read, add, change and delete.
A table policy is a list of rules on one table, in the spirit of Row Level Security in Postgres or Security Rules in Firebase. Each rule is a condition on the row itself.
[
{ "action": "select", "using": "true" },
{ "action": "insert", "check": "row.by == me" },
{ "action": "update", "using": "row.by == me" },
{ "action": "update", "using": "me in row.Assignee", "columns": ["Status"] },
{ "action": "delete", "using": "row.by == me" }
]Members see every task, add their own, edit and delete what they created, and the assignee can change only the Status column.
Who is subject to policies
Owners and editors are not limited: they build the table. Policies apply to people with the view or comment role, link visitors and guests. To have someone work under the rules, invite them with the view role on the table, folder or project, then write rules that let them write.
Rule fields
| Field | Meaning |
|---|---|
action | select, insert, update or delete. |
appliesTo | Who the rule applies to, joined with |: members (has a role on the table and is signed in; default), public (anyone who can open the table, including guests), owner, edit, comment, view. |
using | Condition the existing row must meet (select, update, delete). Empty means every row. |
check | Condition the row after the write must meet (insert, update). On update, empty means the same as using. |
columns | Columns that may be read (select) or changed (update), by name. Empty means every column. |
How rules combine
- Rules of the same action are OR-ed. If no rule applies to a person, they cannot perform the action.
- An update is allowed when one update rule matches the old row in
using, every changed column is in itscolumns, and the new row passescheck. - Readable columns are the union of
columnsof the select rules that apply. Other columns are removed from rows and from the column list. inserthas nousing;selectanddeletehave nocheck;columnsexists only on select and update.
Presets
Instead of an array, a policy can be the name of a preset:
| Preset | Rules |
|---|---|
own | select public row.by == me · insert members check row.by == me · update, delete members row.by == me |
read_all_own | Same as own, but select is true. |
append | insert members check row.by == me. |
Setting the policy to null removes the table's own rules, and the row roles chosen in the Share dialog apply again.
Validation
- A rule with a wrong column name, type, option or syntax is rejected with the rule number, the field and the character position. The previous rules stay in place.
- Up to 20 rules per table. A condition is at most 1,000 characters, 200 nodes and 30 levels deep; lists hold up to 50 items.
- Renaming a column makes rules that use the old name invalid. Invalid rules are skipped when applied, so access only narrows. Save the rules again with the new name.
Tables with policies are closed
A page that embeds the table, or an HTML page that names it, does not grant access. Readers need a role on the table itself (invite, folder, project or link), and then the policy applies.