Skip to main content

LoaderTrait

Trait LoaderTrait 

Source
pub trait LoaderTrait {
    type Entity: EntityTrait;

    // Required methods
    fn load_one<'life0, 'life1, 'async_trait, R, C>(
        &'life0 self,
        __arg1: R,
        db: &'life1 C,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<R::Model>>>> + Send + 'async_trait>>
       where R: EntityTrait + 'async_trait,
             Self::Entity: Related<R>,
             C: ConnectionTrait + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_many<'life0, 'life1, 'async_trait, R, C>(
        &'life0 self,
        __arg1: R,
        db: &'life1 C,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
       where R: EntityTrait + 'async_trait,
             Self::Entity: Related<R>,
             C: ConnectionTrait + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_many_to_many<'life0, 'life1, 'async_trait, R, C>(
        &'life0 self,
        __arg1: R,
        db: &'life1 C,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
       where R: EntityTrait + 'async_trait,
             Self::Entity: Related<R>,
             C: ConnectionTrait + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Loads related rows for a batch of models in one query.

Required Associated Types§

Source

type Entity: EntityTrait

The entity of the models in the batch.

Required Methods§

Source

fn load_one<'life0, 'life1, 'async_trait, R, C>( &'life0 self, __arg1: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads, for each model, the related R row if any; for has_one and belongs_to.

The result has one entry per input model, in input order.

§Errors

Returns DbErr::Custom when the relation names a column the entity does not have; DbErr::Driver when the query fails or a row cannot be decoded.

Source

fn load_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, __arg1: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads, for each model, the related R rows; for has_many, and for a many-to-many relation, which is followed through its junction.

The result has one entry per input model, in input order.

§Errors

Returns DbErr::Custom when the relation names a column the entity does not have; DbErr::Driver when the query fails or a row cannot be decoded.

Source

fn load_many_to_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, __arg1: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads, for each model, the R rows reached through the junction table of a many-to-many relation.

load_many does the same when the relation declares a junction; this method exists to make the intent explicit and fails on a direct relation.

§Errors

Returns DbErr::Custom when the relation has no junction or names a column the entity does not have; DbErr::Driver when the query fails or a row cannot be decoded.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<M: ModelTrait> LoaderTrait for Vec<M>

Source§

type Entity = <M as ModelTrait>::Entity

Source§

fn load_one<'life0, 'life1, 'async_trait, R, C>( &'life0 self, r: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, r: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_many_to_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, r: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl<M: ModelTrait> LoaderTrait for [M]

Source§

type Entity = <M as ModelTrait>::Entity

Source§

fn load_one<'life0, 'life1, 'async_trait, R, C>( &'life0 self, __arg1: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Option<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, r: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn load_many_to_many<'life0, 'life1, 'async_trait, R, C>( &'life0 self, __arg1: R, db: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<R::Model>>>> + Send + 'async_trait>>
where R: EntityTrait + 'async_trait, Self::Entity: Related<R>, C: ConnectionTrait + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§