Skip to main content

RELATION

Constant RELATION 

Source
pub const RELATION: ColumnMarker;
Expand description

Names the accessor that loads this table’s rows from the referenced table (the reverse relation).

By default it is the plural of this struct’s name (posts for a Post table), or the singular when this column alone is unique, which loads an Option (profile for a Profile table). A column named for a role rather than the table it references starts the name with the role: author_id gives users.author_posts(), while user_id gives users.posts(). The name depends on this column alone, so relation is needed only to choose another one.

The forward relation (on this table) is unchanged; only the reverse accessor on the referenced table is renamed.

§Examples

// Users get `.authored()` instead of `.author_posts()`
#[column(references = User::id, relation = "authored")]
author_id: i32,

Requires a references attribute on the same column.