diff options
Diffstat (limited to 'entity/src')
| -rw-r--r-- | entity/src/access_to_queue.rs | 15 | ||||
| -rw-r--r-- | entity/src/invite_tokens.rs | 10 | ||||
| -rw-r--r-- | entity/src/queues.rs | 5 | ||||
| -rw-r--r-- | entity/src/users.rs | 5 |
4 files changed, 27 insertions, 8 deletions
diff --git a/entity/src/access_to_queue.rs b/entity/src/access_to_queue.rs index 9de03d5..5244ed0 100644 --- a/entity/src/access_to_queue.rs +++ b/entity/src/access_to_queue.rs | |||
| @@ -9,11 +9,20 @@ pub struct Model { | |||
| 9 | pub user_id: i64, | 9 | pub user_id: i64, |
| 10 | #[sea_orm(primary_key, auto_increment = false)] | 10 | #[sea_orm(primary_key, auto_increment = false)] |
| 11 | pub queue_id: i64, | 11 | pub queue_id: i64, |
| 12 | pub invite_token_id: i64, | ||
| 12 | } | 13 | } |
| 13 | 14 | ||
| 14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | 15 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] |
| 15 | pub enum Relation { | 16 | pub enum Relation { |
| 16 | #[sea_orm( | 17 | #[sea_orm( |
| 18 | belongs_to = "super::invite_tokens::Entity", | ||
| 19 | from = "Column::InviteTokenId", | ||
| 20 | to = "super::invite_tokens::Column::Id", | ||
| 21 | on_update = "Cascade", | ||
| 22 | on_delete = "Cascade" | ||
| 23 | )] | ||
| 24 | InviteTokens, | ||
| 25 | #[sea_orm( | ||
| 17 | belongs_to = "super::queues::Entity", | 26 | belongs_to = "super::queues::Entity", |
| 18 | from = "Column::QueueId", | 27 | from = "Column::QueueId", |
| 19 | to = "super::queues::Column::Id", | 28 | to = "super::queues::Column::Id", |
| @@ -31,6 +40,12 @@ pub enum Relation { | |||
| 31 | Users, | 40 | Users, |
| 32 | } | 41 | } |
| 33 | 42 | ||
| 43 | impl Related<super::invite_tokens::Entity> for Entity { | ||
| 44 | fn to() -> RelationDef { | ||
| 45 | Relation::InviteTokens.def() | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 34 | impl Related<super::queues::Entity> for Entity { | 49 | impl Related<super::queues::Entity> for Entity { |
| 35 | fn to() -> RelationDef { | 50 | fn to() -> RelationDef { |
| 36 | Relation::Queues.def() | 51 | Relation::Queues.def() |
diff --git a/entity/src/invite_tokens.rs b/entity/src/invite_tokens.rs index f239567..c0b59f7 100644 --- a/entity/src/invite_tokens.rs +++ b/entity/src/invite_tokens.rs | |||
| @@ -9,10 +9,14 @@ pub struct Model { | |||
| 9 | pub id: i64, | 9 | pub id: i64, |
| 10 | pub token: Uuid, | 10 | pub token: Uuid, |
| 11 | pub queue_id: i64, | 11 | pub queue_id: i64, |
| 12 | pub name: String, | ||
| 13 | pub is_revoked: bool, | ||
| 12 | } | 14 | } |
| 13 | 15 | ||
| 14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | 16 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] |
| 15 | pub enum Relation { | 17 | pub enum Relation { |
| 18 | #[sea_orm(has_many = "super::access_to_queue::Entity")] | ||
| 19 | AccessToQueue, | ||
| 16 | #[sea_orm( | 20 | #[sea_orm( |
| 17 | belongs_to = "super::queues::Entity", | 21 | belongs_to = "super::queues::Entity", |
| 18 | from = "Column::QueueId", | 22 | from = "Column::QueueId", |
| @@ -23,6 +27,12 @@ pub enum Relation { | |||
| 23 | Queues, | 27 | Queues, |
| 24 | } | 28 | } |
| 25 | 29 | ||
| 30 | impl Related<super::access_to_queue::Entity> for Entity { | ||
| 31 | fn to() -> RelationDef { | ||
| 32 | Relation::AccessToQueue.def() | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 26 | impl Related<super::queues::Entity> for Entity { | 36 | impl Related<super::queues::Entity> for Entity { |
| 27 | fn to() -> RelationDef { | 37 | fn to() -> RelationDef { |
| 28 | Relation::Queues.def() | 38 | Relation::Queues.def() |
diff --git a/entity/src/queues.rs b/entity/src/queues.rs index c6116df..af2714c 100644 --- a/entity/src/queues.rs +++ b/entity/src/queues.rs | |||
| @@ -49,10 +49,7 @@ impl Related<super::queue_elements::Entity> for Entity { | |||
| 49 | 49 | ||
| 50 | impl Related<super::users::Entity> for Entity { | 50 | impl Related<super::users::Entity> for Entity { |
| 51 | fn to() -> RelationDef { | 51 | fn to() -> RelationDef { |
| 52 | super::access_to_queue::Relation::Users.def() | 52 | Relation::Users.def() |
| 53 | } | ||
| 54 | fn via() -> Option<RelationDef> { | ||
| 55 | Some(super::access_to_queue::Relation::Queues.def().rev()) | ||
| 56 | } | 53 | } |
| 57 | } | 54 | } |
| 58 | 55 | ||
diff --git a/entity/src/users.rs b/entity/src/users.rs index 6628c9e..4455f4a 100644 --- a/entity/src/users.rs +++ b/entity/src/users.rs | |||
| @@ -39,10 +39,7 @@ impl Related<super::queue_elements::Entity> for Entity { | |||
| 39 | 39 | ||
| 40 | impl Related<super::queues::Entity> for Entity { | 40 | impl Related<super::queues::Entity> for Entity { |
| 41 | fn to() -> RelationDef { | 41 | fn to() -> RelationDef { |
| 42 | super::access_to_queue::Relation::Queues.def() | 42 | Relation::Queues.def() |
| 43 | } | ||
| 44 | fn via() -> Option<RelationDef> { | ||
| 45 | Some(super::access_to_queue::Relation::Users.def().rev()) | ||
| 46 | } | 43 | } |
| 47 | } | 44 | } |
| 48 | 45 | ||
