Skip to content

Relations Tutorial

Relations Tutorial

This tutorial shows relation declaration and batch loading with LoadBelongsTo.

When to Use

  • Batch loading related entities without N+1 patterns.
  • Typed relation metadata in schema definitions.

Complete Example

Pitfalls

  • Incomplete rel tags (table/local/target) cause relation resolution failure.
  • Incompatible key types between source and target schemas.

Verify

go test ./dbx/... -run Relation