aboutsummaryrefslogtreecommitdiff
path: root/entity/src/queues.rs
blob: 34b358a81389c1cd9742fe1108e0a8c503b7603f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "queues")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub owner_id: i64,
    pub name: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::access_to_queue::Entity")]
    AccessToQueue,
    #[sea_orm(has_many = "super::queue_elements::Entity")]
    QueueElements,
    #[sea_orm(
        belongs_to = "super::users::Entity",
        from = "Column::OwnerId",
        to = "super::users::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    Users,
}

impl Related<super::access_to_queue::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::AccessToQueue.def()
    }
}

impl Related<super::queue_elements::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::QueueElements.def()
    }
}

impl Related<super::users::Entity> for Entity {
    fn to() -> RelationDef {
        super::access_to_queue::Relation::Users.def()
    }
    fn via() -> Option<RelationDef> {
        Some(super::access_to_queue::Relation::Queues.def().rev())
    }
}

impl ActiveModelBehavior for ActiveModel {}