Trait ModelTrait

pub trait ModelTrait:
    Clone
    + Send
    + Debug {
    type Entity: EntityTrait;

    // Required methods
    fn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value;
    fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value);

    // Provided methods
    fn find_related<R>(&self, _: R) -> Select<R>
       where R: EntityTrait,
             Self::Entity: Related<R> { ... }
    fn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>
       where L: Linked<FromEntity = Self::Entity> { ... }
    fn delete<'a, 'async_trait, A, C>(
        self,
        db: &'a C,
    ) -> Pin<Box<dyn Future<Output = Result<DeleteResult, DbErr>> + Send + 'async_trait>>
       where 'a: 'async_trait,
             Self: IntoActiveModel<A> + 'async_trait,
             C: ConnectionTrait + 'async_trait,
             A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'a + 'async_trait { ... }
}
Expand description

The interface for Model, implemented by data structs

Required Associated Types§

Required Methods§

fn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value

Get the Value of a column from an Entity

fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value)

Set the Value of a column in an Entity

Provided Methods§

Find related Models

fn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>
where L: Linked<FromEntity = Self::Entity>,

Find linked Models

fn delete<'a, 'async_trait, A, C>( self, db: &'a C, ) -> Pin<Box<dyn Future<Output = Result<DeleteResult, DbErr>> + Send + 'async_trait>>
where 'a: 'async_trait, Self: IntoActiveModel<A> + 'async_trait, C: ConnectionTrait + 'async_trait, A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'a + 'async_trait,

Delete a model

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl ModelTrait for Model

§

type Entity = Entity

§

fn get( &self, c: <<Model as ModelTrait>::Entity as EntityTrait>::Column, ) -> Value

§

fn set( &mut self, c: <<Model as ModelTrait>::Entity as EntityTrait>::Column, v: Value, )

Implementors§