Skip to main content

RelationAccess

Trait RelationAccess 

Source
pub trait RelationAccess: ModelExt {
    // Provided methods
    fn get_has_many(
        &self,
        name: &str,
    ) -> Result<Vec<HashMap<String, Value>>, RelationError>
       where Self: RelationLoader { ... }
    fn get_has_one(
        &self,
        name: &str,
    ) -> Result<Option<HashMap<String, Value>>, RelationError>
       where Self: RelationLoader { ... }
    fn get_belongs_to_many(
        &self,
        name: &str,
    ) -> Result<Vec<HashMap<String, Value>>, RelationError>
       where Self: RelationLoader { ... }
    fn get_morph_many(
        &self,
        name: &str,
    ) -> Result<Vec<HashMap<String, Value>>, RelationError>
       where Self: RelationLoader { ... }
    fn get_morph_to(
        &self,
        name: &str,
    ) -> Result<Option<HashMap<String, Value>>, RelationError>
       where Self: RelationLoader { ... }
}
Expand description

ModelExt 的关系访问扩展方法

Provided Methods§

Source

fn get_has_many( &self, name: &str, ) -> Result<Vec<HashMap<String, Value>>, RelationError>
where Self: RelationLoader,

获取一对多关系数据(必须先调用 .with(name) 加载)

Source

fn get_has_one( &self, name: &str, ) -> Result<Option<HashMap<String, Value>>, RelationError>
where Self: RelationLoader,

获取一对一或多对一关系数据(必须先加载,返回 0 或 1 行)

Source

fn get_belongs_to_many( &self, name: &str, ) -> Result<Vec<HashMap<String, Value>>, RelationError>
where Self: RelationLoader,

获取多对多关系数据(必须先加载)

Source

fn get_morph_many( &self, name: &str, ) -> Result<Vec<HashMap<String, Value>>, RelationError>
where Self: RelationLoader,

获取多态一对多关系数据(必须先加载) 与 has_many 行为一致,返回多行

Source

fn get_morph_to( &self, name: &str, ) -> Result<Option<HashMap<String, Value>>, RelationError>
where Self: RelationLoader,

获取多态反向关系数据(必须先加载) 与 has_one 行为一致,返回 0 或 1 行

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§