Virtual entity purpose
A virtual entity reads existing persistent data and composes the response you need. Select ordinary fields, related data and collections. It creates neither its own table/storage migrations nor write operations.
For example, a website can request ENTITY_NAME, related RELATED_ENTITY_NAME and ITEM_ENTITY_NAME collection in one projection request rather than querying each separately. Response limits/pagination still apply; one response cannot return unlimited records.
Creation and field selection
- Create an entity with Kind
virtual. - Select a persistent Source entity, such as ENTITY_NAME.
- Enable Read operations: List and/or Get by ID.
- Select source scalar fields.
- For declared relationships, enable Include relation and select Target fields.
- Save; edit later with Configure source and fields / Save fields.
Sources must be persistent, not another projection. Supported one-level relationships are available; arbitrary-depth expand is not. Include only fields needed by the client.
Output name and Fields
Output name controls API naming. For example, return bodyMarkdown as body without renaming the database column. Lowercase-starting lowerCamelCase/snake_case are allowed; empty retains the original name.
Fields shows selected types and capabilities. Related entities have badges and Expand fields, revealing nested rows. Clicking a row opens settings. Inspect the response shape directly in this table.
List behavior at different levels
Enable Searchable, Filterable, Sortable on supported selected scalars. Projection settings are independent of persistent sources.
| Enabled on | Request effect |
|---|---|
| ENTITY_NAME field | Root block list |
| Selected belongsTo RELATED_ENTITY_NAME scalar | Root blocks by related-page value |
| Items collection field | Items within each block |
Sorting by belongsTo RELATED_ENTITY_NAME changes root-block order without creating a separate page list. Sorting items changes each collection, not block order.
Collection limits and order
For hasMany, set Default limit, Maximum limit, Order field and Direction. Limits must be positive integers; Maximum must be at least Default. Order field accepts suitable selected target scalars, not image/gallery.
For items, select position, Ascending, Default limit 20 and Maximum limit 100. The server uses this default independently of Sortable; enable Sortable to let clients override order in requests.
Collection responses contain items, total, limit, offset. Compare total with returned count and account for subsequent pages. Child search/filter/sort parameters belong to a specific collection and do not replace root-list parameters.
Publication and visibility
Open Access, enable needed external List/Get and separate server conditions for ENTITY_NAME, RELATED_ENTITY_NAME and items. For example: visible block, published page, visible item with nonempty title. Child rules restrict collection contents only: an empty collection does not exclude its parent.
Persistent access does not automatically carry into virtual. Check projection rules and every selected field before Anonymous.
Translations of selected fields
Configure languages on persistent sources in Languages. A virtual entity combines the languages of entities whose translated fields you select, including belongsTo and hasMany. A VIRTUAL_ENTITY_NAME based on an ordinary RELATED_ENTITY_NAME therefore gains a language selector when the related COLLECTION_NAME collection contain selected translated fields. Configuring ENTITY_NAME languages alone is not enough: a translated ENTITY_NAME field must be selected.
Use Content language in the admin or ?locale=ru in the API. The selection applies to translated values and collection search, filters and sorting. Each source has its own missing-translation policy; the virtual entity has no separate translation store. Edit texts in source records. See languages and translations for an example and fallback rules.
Administrator view
Projections are read-only in the admin. Related data is readable; collections show counts and pages. Administrative media reads require source persistent permissions. External images are variant URLs; see Images.
Changing Source entity with confirmation clears selected fields in the draft. Select new-source fields before saving. Finish/Save fields saves the model; Generate updates code.
See CLI virtual entities.
Field order
Move selected virtual fields in the generator's field inventory, as with persistent fields. This controls their authored display order; it does not sort records returned by the API. Configure record/collection sorting separately in list behavior and collection settings. A source-record navigation action is shown only when the user can read that persistent record.
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.