Skip to main content

RelationTrait

Trait RelationTrait 

Source
pub trait RelationTrait: Send + Sync {
    // Required methods
    fn def(&self) -> &'static RelationDef;
    fn all_relations() -> &'static [RelationDef]
       where Self: Sized;

    // Provided method
    fn relation_by_name(name: &str) -> Option<&'static RelationDef>
       where Self: Sized { ... }
}
Expand description

关联关系 trait — 由 #[derive(Relation)] 自动实现

提供关联定义访问和批量关联查询能力。 实体类型实现此 trait 后,可通过 QueryBuilder::join() 链式构建 JOIN 查询。

Required Methods§

Source

fn def(&self) -> &'static RelationDef

返回当前关联的定义

Source

fn all_relations() -> &'static [RelationDef]
where Self: Sized,

返回实体所有关联定义的静态切片

Provided Methods§

Source

fn relation_by_name(name: &str) -> Option<&'static RelationDef>
where Self: Sized,

按名称查找关联定义

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§