ModelTrait

Trait ModelTrait 

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

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

    // Provided methods
    fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value) { ... }
    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, A, C>(self, db: &'a C) -> Result<DeleteResult, DbErr>
       where Self: IntoActiveModel<A>,
             C: ConnectionTrait,
             A: ActiveModelTrait<Entity = Self::Entity> + ActiveModelBehavior + 'a { ... }
    fn get_primary_key_value(&self) -> ValueTuple { ... }
}
Expand description

The interface for Model, implemented by data structs

Required Associated Typesยง

Required Methodsยง

Source

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

Get the Value of a column from a Model

Source

fn get_value_type(c: <Self::Entity as EntityTrait>::Column) -> ArrayType

Get the Value Type of a column from the Model

Source

fn try_set( &mut self, c: <Self::Entity as EntityTrait>::Column, v: Value, ) -> Result<(), DbErr>

Set the Value of a Model field, return error if failed

Provided Methodsยง

Source

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

Set the Value of a Model field, panic if failed

Find related Models belonging to self

Source

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

Find linked Models belonging to self

Source

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

Delete a model

Source

fn get_primary_key_value(&self) -> ValueTuple

Get the primary key value of the 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ยง

Sourceยง

impl ModelTrait for sea_orm::rbac::entity::permission::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::resource::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::role::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::role_hierarchy::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::role_permission::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::user_override::Model

Available on crate feature rbac only.
Sourceยง

impl ModelTrait for sea_orm::rbac::entity::user_role::Model

Available on crate feature rbac only.