pub trait ModelTrait:
Clone
+ Send
+ Sync
+ Debug {
type Entity: EntityTrait<Model = Self>;
// Required methods
fn get(&self, column: <Self::Entity as EntityTrait>::Column) -> Value;
fn set(
&mut self,
column: <Self::Entity as EntityTrait>::Column,
value: Value,
) -> Result<()>;
// Provided methods
fn find_related<R>(&self, _: R) -> Select<R>
where R: EntityTrait,
Self::Entity: Related<R> { ... }
fn find_linked<L>(&self, link: L) -> Select<L::ToEntity>
where L: Linked<FromEntity = Self::Entity> { ... }
fn delete<'life0, 'async_trait, C>(
self,
db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult>> + Send + 'async_trait>>
where C: ConnectionTrait + 'async_trait,
Self: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel> + 'async_trait,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior,
'life0: 'async_trait { ... }
}Expand description
A row of an entity as a plain struct, derived by DeriveEntityModel.
Required Associated Types§
Sourcetype Entity: EntityTrait<Model = Self>
type Entity: EntityTrait<Model = Self>
The entity this model belongs to.
Required Methods§
Sourcefn get(&self, column: <Self::Entity as EntityTrait>::Column) -> Value
fn get(&self, column: <Self::Entity as EntityTrait>::Column) -> Value
Reads a column as a SQL value.
Sourcefn set(
&mut self,
column: <Self::Entity as EntityTrait>::Column,
value: Value,
) -> Result<()>
fn set( &mut self, column: <Self::Entity as EntityTrait>::Column, value: Value, ) -> Result<()>
Writes a column from a SQL value.
§Errors
Returns DbErr::Type when the value cannot be decoded as the field type.
Provided Methods§
Builds a query for the rows of R related to this model, following
the junction table of a many-to-many relation when there is one.
Sourcefn find_linked<L>(&self, link: L) -> Select<L::ToEntity>
fn find_linked<L>(&self, link: L) -> Select<L::ToEntity>
Builds a query for the rows reached from this model through the
chain link.
Sourcefn delete<'life0, 'async_trait, C>(
self,
db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult>> + Send + 'async_trait>>where
C: ConnectionTrait + 'async_trait,
Self: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel> + 'async_trait,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior,
'life0: 'async_trait,
fn delete<'life0, 'async_trait, C>(
self,
db: &'life0 C,
) -> Pin<Box<dyn Future<Output = Result<DeleteResult>> + Send + 'async_trait>>where
C: ConnectionTrait + 'async_trait,
Self: IntoActiveModel<<Self::Entity as EntityTrait>::ActiveModel> + 'async_trait,
<Self::Entity as EntityTrait>::ActiveModel: ActiveModelBehavior,
'life0: 'async_trait,
Deletes the row this model was read from, running the active model’s
ActiveModelBehavior hooks.
§Errors
Returns the errors of ActiveModelTrait::delete.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".