Relationships And Child Records
- A named entity type describes a nominal relationship; an indexed string ID gives explicit query control.
- Core child entities use Parent.child naming and durable parent-ID plus child-key identity.
- The current App Marché authoring surface may require a top-level indexed record instead of a dotted child source file.
Named References And Indexed IDs
1entity Expense {2 payer: User3 amount: number4}Use a named reference when the field is conceptually the referenced entity value. Use an explicit indexed ID when workflows need direct filtering, independent lifecycle control, or a host boundary that exposes identifiers rather than entity values.
Self References
1entity ExpenseCategory {2 label: string3 parent: ExpenseCategory?4 children: ExpenseCategory[]5}A self-reference uses the entity’s own nominal type. Make a single parent optional to represent the root. Use an empty array rather than an optional array for no children.
Core Child Entity Syntax
1entity Expense.shares {2 member: User3 amount: number4}- The parent name is PascalCase.
- The child segment is lower-camel.
Expense.sharesis valid;Expense.Sharesis not.- A child record’s stable identity combines the parent identity and child key.
Create Or Load One Child
1need {2 member = User(request.member_id)3 share = Expense(request.expense_id).shares(request.member_id) | default4}56share.member = member7share.amount = request.amount8save(share)An exact child need plus | default can create the missing child because the parent ID and exact child key provide durable identity. A query-shaped child fetch cannot use this creation form.
Top-Level Alternative In App Marché
1entity ExpenseShare {2 expense_id: string @index3 member: User4 amount: number5}When the current project editor exposes only top-level entity nodes, model the child as a top-level record with an indexed parent ID. This is an App Marché authoring boundary, not a claim that core child syntax is invalid.
Common Mistakes
| Wrong | Correct |
|---|---|
Expense.Shares | Expense.shares |
| Optional child array | Use an empty non-optional array. |
| default on a filtered child query | Use an exact child key. |
| Assume every App Marché node accepts dotted child files | Use the active authoring surface or a top-level indexed record. |
