kellnr_entity/
group_user.rs1use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "group_user")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: i64,
10 pub group_fk: i64,
11 pub user_fk: i64,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(
17 belongs_to = "super::group::Entity",
18 from = "Column::GroupFk",
19 to = "super::group::Column::Id",
20 on_update = "NoAction",
21 on_delete = "Cascade"
22 )]
23 Group,
24 #[sea_orm(
25 belongs_to = "super::user::Entity",
26 from = "Column::UserFk",
27 to = "super::user::Column::Id",
28 on_update = "NoAction",
29 on_delete = "Cascade"
30 )]
31 User,
32}
33
34impl Related<super::group::Entity> for Entity {
35 fn to() -> RelationDef {
36 Relation::Group.def()
37 }
38}
39
40impl Related<super::user::Entity> for Entity {
41 fn to() -> RelationDef {
42 Relation::User.def()
43 }
44}
45
46impl ActiveModelBehavior for ActiveModel {}