Documentation
¶
Overview ¶
Package relation provides explicit loaded states for typed model relations. Reading a relation value never performs database I/O.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Link ¶
type Link[M, P any] struct { Model M Pivot P }
Link keeps each related model beside the concrete pivot model for that edge. A target shared by several parents never acquires another parent's pivot data.
type Many ¶
type Many[M any] struct { // contains filtered or unexported fields }
Many distinguishes not loaded from a loaded collection, including an empty collection. Its private slice is copied at construction and retrieval.
func Collection ¶
Collection constructs a loaded relation with a shallow copy of items, including an empty collection.
func FoundryCollection ¶
func FoundryCollection[M any](seal sqlowner.CollectionSeal, items []M) Many[M]
FoundryCollection publishes a caller-independent collection for framework loaders. An invalid capability leaves the relation unloaded.
func (Many[M]) All ¶
All yields each loaded item by value without copying the collection. Nothing is yielded when the relation is not loaded.
func (Many[M]) Get ¶
Get returns a caller-owned copy and whether the collection was loaded. Use Len and All to read a large collection without copying it.
type One ¶
type One[M any] struct { // contains filtered or unexported fields }
One distinguishes not loaded, loaded empty and loaded with a model. Its private pointer permits self-relations without an infinitely sized Go struct.
type Through ¶
type Through[M, P any] struct { // contains filtered or unexported fields }
Through is a loaded many-to-many collection with typed pivot data. Distinct pivot rows remain distinct links even when they refer to the same target.
func FoundryLinked ¶
func FoundryLinked[M, P any](seal sqlowner.CollectionSeal, items []Link[M, P]) Through[M, P]
FoundryLinked publishes a caller-independent link collection for framework loaders. Only framework loaders can issue a valid seal; applications use Linked.
func (Through[M, P]) Get ¶
Get returns a copied link collection and whether it was loaded. Model fields inside each link retain ordinary Go value-copy semantics.
type Value ¶
type Value[V any] struct { // contains filtered or unexported fields }
Value is a loaded aggregate slot. V describes SQL nullability independently of loaded state: for example Value[value.Nullable[decimal.Decimal]].