nenu-lang / relationships-and-children
Stable

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

code
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

code
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

entities/Expense.shares.entity.nenu
1entity Expense.shares {2  member: User3  amount: number4}
  • The parent name is PascalCase.
  • The child segment is lower-camel.
  • Expense.shares is valid; Expense.Shares is not.
  • A child record’s stable identity combines the parent identity and child key.

Create Or Load One Child

code
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é

code
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

WrongCorrect
Expense.SharesExpense.shares
Optional child arrayUse an empty non-optional array.
| default on a filtered child queryUse an exact child key.
Assume every App Marché node accepts dotted child filesUse the active authoring surface or a top-level indexed record.

Continue Learning