Choose field access and references
Index queries, hide private fields and reference other records.
Before you begin: Define a record schema.
Query Indexes
Declare fields you plan to filter, sort, or search. Frontbacked uses the schema and your theme queries to keep large lists fast.
Reference fields can be filtered by their saved ID. The typed suffix is optional, but can be useful when you want the selector to be explicit:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Field Visibility
In FRL version 2, schema fields can declare visibility when a value should not be returned to normal theme pages.
Rule input (JSON)
Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.
Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.
Visibility values by requester:
| Visibility | Visitor or guest | Signed-in non-author | Post author | FRL rules/endpoints |
|---|---|---|---|---|
public | Visible if the post itself is readable. | Visible if the post itself is readable. | Visible if the post itself is readable. | Visible. |
author | Hidden. | Hidden. | Visible. | Visible. |
backend | Hidden. | Hidden. | Hidden. | Visible. |
public is the default when visibility is not declared. Admin status does not automatically bypass field visibility in normal theme page data; an admin viewing through the site frontend still receives the same field visibility as their requester identity. Use FRL rules or endpoint handlers for values that must remain server-only.
Visibility inherits downward. If an object field is author, its nested fields are also author-only unless a nested field is stricter, such as backend. Array visibility applies to every item in the array; numeric array indexes in field paths are ignored.
When a post type has restricted fields, search only checks fields the current reader is allowed to see. Hidden values cannot match a visitor search or filter.
Supported Types
| Type | Accepts | Typical use |
|---|---|---|
string | JavaScript string values | Names, emails, titles, slugs, statuses. |
email | Email-like string values | Account or contact email fields. |
phone | Phone number strings with a country code | Contact numbers, account phone fields, support phone fields. |
enum | One string from a declared set | Publish states, plan tiers, workflow steps. |
user | Generated user IDs | Owner, assignee, member, or customer references. |
number | JavaScript number values | Counts, measurements, percentages. |
money | An amount whose currency follows the site's currency settings | Account balances, credits, debits, ledger entries. |
boolean | true or false | Checkboxes, toggles, feature flags. |
datetime | Date strings or Date values | Event dates, expiry dates, scheduled times. |
serverTime | Frontbacked-managed timestamp values | createdAt, updatedAt. |
post | Existing post IDs from another post type | Category, author, parent, or related-record references. |
object | Plain objects | Structured settings, address fields, nested metadata. |
array | Arrays | Tags, gallery images, feature lists. |
file | Uploaded file metadata objects | Images, videos, PDFs, audio, documents. |
anyOf | One of several field schema objects | Flexible values such as string or number. |
Reference Fields
Use type: "post" for a field that points to another post, and type: "user" for a field that points to a site user.
Rule input (JSON)
Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.
Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.
Send IDs from the frontend:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Post references are saved as post IDs, and user references are saved as user IDs. Do not save copied post or user objects into reference fields.
When a theme page asks for a visible reference field, Frontbacked expands it in place. A field named category can be read as category.name, and mentor can be read as mentor.name. Each expanded reference also includes id.
Nested references can be read through the same field names. For example, if reviews.product points to a product, and products.category points to a category, a theme can read review.product.category.name. Frontbacked expands only the requested reference chain, up to five reference hops.
Use visibility on the reference field when those user details should only be returned to the author or kept for FRL rules and endpoint handlers.
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
Related creates and edits from post.* helpers follow the same schema rules as normal saves. If a required reference field is missing from the helper data, the write fails with the normal schema error.
Continue with Validate text and numbers.