Trait leetcode_tui_rs::migrations::sea_orm::entity::prelude::ActiveModelBehavior
source · pub trait ActiveModelBehavior: ActiveModelTrait {
// Provided methods
fn new() -> Self { ... }
fn before_save<'life0, 'async_trait, C>(
self,
db: &'life0 C,
insert: bool
) -> Pin<Box<dyn Future<Output = Result<Self, DbErr>> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait { ... }
fn after_save<'life0, 'async_trait, C>(
model: <Self::Entity as EntityTrait>::Model,
db: &'life0 C,
insert: bool
) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model, DbErr>> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait { ... }
fn before_delete<'life0, 'async_trait, C>(
self,
db: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Self, DbErr>> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait { ... }
fn after_delete<'life0, 'async_trait, C>(
self,
db: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Self, DbErr>> + Send + 'async_trait, Global>>
where 'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait { ... }
}
Expand description
A Trait for overriding the ActiveModel behavior
Example
ⓘ
use sea_orm::entity::prelude::*;
// Use [DeriveEntity] to derive the EntityTrait automatically
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
pub struct Entity;
/// The [EntityName] describes the name of a table
impl EntityName for Entity {
fn table_name(&self) -> &str {
"cake"
}
}
// Derive the ActiveModel
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
pub struct Model {
pub id: i32,
pub name: String,
}
impl ActiveModelBehavior for ActiveModel {}
See module level docs crate::entity for a full example
Provided Methods§
sourcefn new() -> Self
fn new() -> Self
Create a new ActiveModel with default values. Also used by Default::default()
.
sourcefn before_save<'life0, 'async_trait, C>(
self,
db: &'life0 C,
insert: bool
) -> Pin<Box<dyn Future<Output = Result<Self, DbErr>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait,
fn before_save<'life0, 'async_trait, C>( self, db: &'life0 C, insert: bool ) -> Pin<Box<dyn Future<Output = Result<Self, DbErr>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, C: ConnectionTrait + 'async_trait, Self: Send + 'async_trait,
Will be called before ActiveModel::insert
, ActiveModel::update
, and ActiveModel::save
sourcefn after_save<'life0, 'async_trait, C>(
model: <Self::Entity as EntityTrait>::Model,
db: &'life0 C,
insert: bool
) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model, DbErr>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
C: ConnectionTrait + 'async_trait,
Self: Send + 'async_trait,
fn after_save<'life0, 'async_trait, C>( model: <Self::Entity as EntityTrait>::Model, db: &'life0 C, insert: bool ) -> Pin<Box<dyn Future<Output = Result<<Self::Entity as EntityTrait>::Model, DbErr>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, C: ConnectionTrait + 'async_trait, Self: Send + 'async_trait,
Will be called after ActiveModel::insert
, ActiveModel::update
, and ActiveModel::save