From 5ffd8025f2ada61ee44ae59af49c98fd5f275624 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sun, 29 Jan 2023 11:34:28 +0800 Subject: [PATCH] Update prelude --- examples/basic/src/example_cake.rs | 10 +++++++++- src/entity/prelude.rs | 10 ++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/basic/src/example_cake.rs b/examples/basic/src/example_cake.rs index b3364df8..6d877ac6 100644 --- a/examples/basic/src/example_cake.rs +++ b/examples/basic/src/example_cake.rs @@ -37,4 +37,12 @@ impl Related for Entity { } } -impl ActiveModelBehavior for ActiveModel {} +#[async_trait::async_trait] +impl ActiveModelBehavior for ActiveModel { + async fn before_save(self, _db: &C, _insert: bool) -> Result + where + C: ConnectionTrait, + { + Ok(self) + } +} diff --git a/src/entity/prelude.rs b/src/entity/prelude.rs index 47b22bcc..2e69f9c0 100644 --- a/src/entity/prelude.rs +++ b/src/entity/prelude.rs @@ -1,9 +1,9 @@ pub use crate::{ error::*, ActiveEnum, ActiveModelBehavior, ActiveModelTrait, ColumnDef, ColumnTrait, - ColumnType, ColumnTypeTrait, CursorTrait, DatabaseConnection, DbConn, EntityName, EntityTrait, - EnumIter, ForeignKeyAction, Iden, IdenStatic, Linked, LoaderTrait, ModelTrait, PaginatorTrait, - PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, QueryResult, Related, RelationDef, - RelationTrait, Select, Value, + ColumnType, ColumnTypeTrait, ConnectionTrait, CursorTrait, DatabaseConnection, DbConn, + EntityName, EntityTrait, EnumIter, ForeignKeyAction, Iden, IdenStatic, Linked, LoaderTrait, + ModelTrait, PaginatorTrait, PrimaryKeyToColumn, PrimaryKeyTrait, QueryFilter, QueryResult, + Related, RelationDef, RelationTrait, Select, Value, }; #[cfg(feature = "macros")] @@ -13,6 +13,8 @@ pub use crate::{ DerivePrimaryKey, DeriveRelation, FromJsonQueryResult, }; +pub use async_trait; + #[cfg(feature = "with-json")] pub use serde_json::Value as Json;