use sea_orm::entity::prelude::*; pub use crate::models::_entities::currencies::{ActiveModel, Column, Entity, Model}; pub type Currencies = Entity; #[async_trait::async_trait] impl ActiveModelBehavior for ActiveModel { async fn before_save(self, _db: &C, insert: bool) -> std::result::Result where C: ConnectionTrait, { if !insert && self.updated_at.is_unchanged() { let mut this = self; this.updated_at = sea_orm::ActiveValue::Set(chrono::Utc::now().into()); Ok(this) } else { Ok(self) } } } // implement your read-oriented logic here impl Model {} // implement your write-oriented logic here impl ActiveModel {} // implement your custom finders, selectors oriented logic here impl Entity { /// An enabled currency by its ISO code (case-insensitive), or `None`. pub async fn find_enabled_by_code( db: &C, code: &str, ) -> Result, DbErr> { Entity::find() .filter(Column::Code.eq(code.to_uppercase())) .filter(Column::Enabled.eq(true)) .one(db) .await } }