sea_orm::entity

Trait ModelTrait

Source
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::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 Self: IntoActiveModel<A> + 'async_trait,
             C: ConnectionTrait + 'async_trait,
             A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + Send + 'a + 'async_trait,
             'a: 'async_trait { ... }
}
Expand description

A Trait for a Model

Required Associated Types§

Required Methods§

Source

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

Get the Value of a column from an Entity

Source

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

Source

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

Find linked Models

Source

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

Implementors§