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 implemented by every Model — an instance of an
EntityTrait, roughly an OOP “object” whose fields are the table’s
columns.
Implemented automatically by #[derive(DeriveEntityModel)] /
#[derive(DeriveModel)]. Pairs with an ActiveModelTrait type for
mutations.
Required Associated Types§
Sourcetype Entity: EntityTrait
type Entity: EntityTrait
The EntityTrait this model belongs to.
Required Methods§
Sourcefn get_value_type(c: <Self::Entity as EntityTrait>::Column) -> ArrayType
fn get_value_type(c: <Self::Entity as EntityTrait>::Column) -> ArrayType
Type of the value stored by a column, used by reflection helpers such as Arrow conversion.
Provided Methods§
Sourcefn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value)
fn set(&mut self, c: <Self::Entity as EntityTrait>::Column, v: Value)
Write a value to one column. Panics if the value’s type doesn’t match
the column; prefer try_set when the value comes
from untrusted input.
Build a Select for models related to self via the
Self::Entity: Related<R> relation. Use it together with .one(db) /
.all(db) to fetch the related rows.
Sourcefn find_linked<L>(&self, l: L) -> Select<L::ToEntity>
fn find_linked<L>(&self, l: L) -> Select<L::ToEntity>
Sourcefn 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 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
Sourcefn get_primary_key_value(&self) -> ValueTuple
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".
Implementors§
Source§impl ModelTrait for sea_orm::rbac::entity::permission::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::permission::Model
rbac only.Source§impl ModelTrait for sea_orm::rbac::entity::resource::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::resource::Model
rbac only.Source§impl ModelTrait for sea_orm::rbac::entity::role::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::role::Model
rbac only.Source§impl ModelTrait for sea_orm::rbac::entity::role_hierarchy::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::role_hierarchy::Model
rbac only.Source§impl ModelTrait for sea_orm::rbac::entity::role_permission::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::role_permission::Model
rbac only.Source§impl ModelTrait for sea_orm::rbac::entity::user_override::Model
Available on crate feature rbac only.
impl ModelTrait for sea_orm::rbac::entity::user_override::Model
rbac only.