Concepts · 0.8.1

Virtual entities: selected fields and nested collections

Build API responses from existing records, with separate conditions, search and ordering for their parts.

On this page

A virtual entity, or projection, builds a response from selected fields of an existing persistent entity. For example, return a page block together with page data and its items. No new table is created and no data copied.

Responses can include source fields, direct belongsTo relationships and bounded hasMany/manyToMany collections. Virtual entities are read-only.

Selecting fields in the UI

Open Content → New entity, select virtual and its source persistent entity. Enter a name and module. Under Fields → Configure fields, select root fields and necessary direct relationships, then Finish.

Selected fields may have output aliases. These change API response names, not database columns. All output names must be unique.

Search, filters and ordering

Enable Searchable, Filterable and Sortable for suitable scalar fields. Configure these independently on the projection: source-field flags are not inherited. Search finds text containment for string and text, and exact values for int, int64 and uuid, including eligible ID fields. It does not search fragments of a numeric identifier.

BelongsTo fields participate in root-list search and filtering; sorting them changes root-record order. Each collection has its own Default limit, Maximum limit, default order and permitted field operations.

For example, sorting pageItems by position orders items separately within each block. The primary key stabilizes order when values are equal.

Records available through external API

Access contains Entity CRUD access, External READ access and Generated routes. External read rules are separated by source, direct belongsTo relationships and selected collections. Combine conditions within each section using AND/OR.

For blocks of published pages with visible items:

  • RELATED_ENTITY_NAME.status = published limits the pages associated with blocks.
  • ENTITY_NAME.isVisible = true keeps visible blocks.
  • ITEM_ENTITY_NAME.isVisible = true AND bodyMarkdown != an empty string selects items within each block.

The last rule does not hide a block without matching items: it retains an empty collection.

Add conditions with + Add. The icon before the trash button wraps a condition in a group; the trash button removes the condition or group. An empty text value means "", not NULL.

Rules belong to the virtual entity independently and are not inherited from source APIs. They restrict external list/get without changing administrative reads.

Viewing the result

After Generate and updating the application, open the virtual entity in the admin. The list displays selected fields; Details displays related data. Collections support their permitted search, filters, sorting and pagination. Edit records through their persistent entity.

Selecting response language

?locale=ru requests Russian values for selected translated fields. A virtual entity's accepted languages combine those of participating root and related fields; the root itself need not have translations. Without the parameter, each field owner uses its own default. A missing related translation returns null or follows that owner's default-language fallback. Shared fields remain shared.

The admin shows Content language for such projections. Configure languages and translated fields on persistent sources, not the virtual entity. See step-by-step setup and API behavior.

Conditions from an API client

Root lists use limit, offset, searches, filters, sort, order. A collection aliased items uses pageItemsLimit, pageItemsOffset, pageItemsSearches, pageItemsFilters, pageItemsSort, pageItemsOrder.

pageItemsSort=position&pageItemsOrder=asc
pageItemsFilters=[{"field":"title","op":"ne","value":""}]

Client filters use selected fields' output names; generator rules use source names. Client conditions are added to mandatory rules and cannot override them.

The server filters first, counts total, then paginates. Within one list request, collection parameters are the same for every parent. Admin Details provides separate collection controls.

Changing a projection

Projections cannot edit nested records. Selected direct relationships are supported; arbitrary response expansion or projections based on another projection are not. Collections are loaded in batches: one HTTP request does not necessarily mean one SQL query.

After changing fields, rules or models, Generate and restart the application. Review selections when changing source. An invalid field or rule reference produces a save/generation error rather than being silently removed.

Steps: Content: virtual entities, Content: access. For automation, use CLI: projections.

Identity and images

The source primary key is selected automatically and its Primary key checkbox cannot be cleared. It identifies list rows and supports Get by ID; no new table or database key is created. The current editor has no separate switch to omit that key from the projection result while retaining this identity.

Read-only images use compact, left-aligned previews, and gallery displays all included images. Edit them in the source persistent record with the required permissions.