Skip to main content

Module relation

Module relation 

Source
Available on crate features model-mysql or model-postgres or model-sqlite only.
Expand description

Async relationship helpers: HasMany, HasOne, BelongsTo, and BelongsToMany (18.30.0) through a join table.

These are explicit-load helpers — no hidden N+1 queries, no lazy loading. Call .load(&pool) when you want the related records. Soft-deleted related rows (#[soft_delete]) are left out. To load a relation for a whole result set, see Relation and QueryBuilder::with.

Structs§

BelongsTo
Represents the inverse side of a relationship (child → owner).
BelongsToMany
Many-to-many through a join table (18.30.0): the rows of R one owner is linked to, and the links themselves — attach, detach, sync.
HasMany
Represents a one-to-many relationship from an owner to a collection of T.
HasOne
Represents a one-to-one relationship (owner → child).
SyncChanges
What BelongsToMany::sync changed: the related keys it linked and unlinked.