What the expressions see
| Binding | Type | Contains |
|---|---|---|
auth.userId | string | null | Current user’s id, null if unauthenticated |
auth.email | string | null | Email of the authenticated user |
auth.roles | string[] | Role names attached to the session |
data.* | object | The row being written (insert/update/delete) |
existing.* | object | The current row in storage (update/delete only) |
Each action
allowRead— runs on query results. If false, row is filtered out.allowInsert— runs against the proposeddata.allowUpdate— runs against bothdata(the patch) andexisting(the current row).allowDelete— runs againstexisting.
Operators
Examples
Public read, author-only write
Members of an org
Admin override
Policy composition
Multiple policies on the same entity AND together — all must pass. Use this to layer a broad rule with a narrow exception:Server functions bypass policies
Policies guard the raw/api/entities/* endpoints. Server functions (ctx.db.insert, ctx.db.update, etc.) run with elevated access — they trust you to enforce your own checks inside the handler. This lets you write escape-hatch operations (admin tools, batch imports) without contorting your policy language.
Next
Functions
Write server logic for anything policies can’t express.
Live queries
Policies also filter subscription results.