DocsSchemas · FRL
On this page

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:

js

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.

backend/index.frl
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:

VisibilityVisitor or guestSigned-in non-authorPost authorFRL rules/endpoints
publicVisible if the post itself is readable.Visible if the post itself is readable.Visible if the post itself is readable.Visible.
authorHidden.Hidden.Visible.Visible.
backendHidden.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

TypeAcceptsTypical use
stringJavaScript string valuesNames, emails, titles, slugs, statuses.
emailEmail-like string valuesAccount or contact email fields.
phonePhone number strings with a country codeContact numbers, account phone fields, support phone fields.
enumOne string from a declared setPublish states, plan tiers, workflow steps.
userGenerated user IDsOwner, assignee, member, or customer references.
numberJavaScript number valuesCounts, measurements, percentages.
moneyAn amount whose currency follows the site's currency settingsAccount balances, credits, debits, ledger entries.
booleantrue or falseCheckboxes, toggles, feature flags.
datetimeDate strings or Date valuesEvent dates, expiry dates, scheduled times.
serverTimeFrontbacked-managed timestamp valuescreatedAt, updatedAt.
postExisting post IDs from another post typeCategory, author, parent, or related-record references.
objectPlain objectsStructured settings, address fields, nested metadata.
arrayArraysTags, gallery images, feature lists.
fileUploaded file metadata objectsImages, videos, PDFs, audio, documents.
anyOfOne of several field schema objectsFlexible 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.

backend/index.frl
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:

js

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.

frl

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.