pub trait ModelTrait:
Clone
+ Send
+ 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 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 { ... }
fn get_primary_key_value(&self) -> ValueTuple { ... }
}Expand description
The interface for Model, implemented by data structs
Required Associated Types§
type Entity: EntityTrait
Required Methods§
Sourcefn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value
fn get(&self, c: <Self::Entity as EntityTrait>::Column) -> Value
Get the Value of a column from a Model
Sourcefn get_value_type(c: <Self::Entity as EntityTrait>::Column) -> ArrayType
fn get_value_type(c: <Self::Entity as EntityTrait>::Column) -> ArrayType
Get the Value Type of a column from the Model
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)
Set the Value of a Model field, panic if failed
Find related Models belonging to self
Sourcefn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>
fn find_linked<L>(&self, l: L) -> Select<<L as Linked>::ToEntity>
Find linked Models belonging to self
Sourcefn 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,
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
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", so this trait is not object safe.