use pagetop_seaorm::db::*; #[derive(Clone, Debug, DeriveEntityModel, PartialEq)] #[sea_orm(table_name = "user_roles")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub user_id: i32, #[sea_orm(primary_key, auto_increment = false)] pub role_id: i32, } #[derive(Clone, Copy, Debug, DeriveRelation, EnumIter)] pub enum Relation { #[sea_orm( belongs_to = "super::user::Entity", from = "Column::UserId", to = "super::user::Column::Id", on_delete = "Cascade" )] User, #[sea_orm( belongs_to = "super::role::Entity", from = "Column::RoleId", to = "super::role::Column::Id", on_delete = "Cascade" )] Role, } impl Related for Entity { fn to() -> RelationDef { Relation::User.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Role.def() } } impl ActiveModelBehavior for ActiveModel {}