From 4d89b0e8b76f1ef17c5e9ce848467b4f5044d220 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 3 Aug 2022 00:31:47 +0000 Subject: [PATCH] entities --- entities/src/block_list.rs | 24 +++++++++++++++++++ entities/src/mod.rs | 9 +++++++ entities/src/prelude.rs | 6 +++++ entities/src/sea_orm_active_enums.rs | 14 +++++++++++ entities/src/secondary_user.rs | 36 ++++++++++++++++++++++++++++ entities/src/user.rs | 36 ++++++++++++++++++++++++++++ entities/src/user_keys.rs | 35 +++++++++++++++++++++++++++ 7 files changed, 160 insertions(+) create mode 100644 entities/src/block_list.rs create mode 100644 entities/src/mod.rs create mode 100644 entities/src/prelude.rs create mode 100644 entities/src/sea_orm_active_enums.rs create mode 100644 entities/src/secondary_user.rs create mode 100644 entities/src/user.rs create mode 100644 entities/src/user_keys.rs diff --git a/entities/src/block_list.rs b/entities/src/block_list.rs new file mode 100644 index 00000000..203f3aec --- /dev/null +++ b/entities/src/block_list.rs @@ -0,0 +1,24 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "block_list")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub address: String, + pub chain: i32, + pub description: String, +} + +#[derive(Copy, Clone, Debug, EnumIter)] +pub enum Relation {} + +impl RelationTrait for Relation { + fn def(&self) -> RelationDef { + panic!("No RelationDef") + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/entities/src/mod.rs b/entities/src/mod.rs new file mode 100644 index 00000000..2562127e --- /dev/null +++ b/entities/src/mod.rs @@ -0,0 +1,9 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +pub mod prelude; + +pub mod block_list; +pub mod sea_orm_active_enums; +pub mod secondary_user; +pub mod user; +pub mod user_keys; diff --git a/entities/src/prelude.rs b/entities/src/prelude.rs new file mode 100644 index 00000000..546ea7a0 --- /dev/null +++ b/entities/src/prelude.rs @@ -0,0 +1,6 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +pub use super::block_list::Entity as BlockList; +pub use super::secondary_user::Entity as SecondaryUser; +pub use super::user::Entity as User; +pub use super::user_keys::Entity as UserKeys; diff --git a/entities/src/sea_orm_active_enums.rs b/entities/src/sea_orm_active_enums.rs new file mode 100644 index 00000000..c10b6d0a --- /dev/null +++ b/entities/src/sea_orm_active_enums.rs @@ -0,0 +1,14 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +use sea_orm::entity::prelude::*; + +#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] +#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "role")] +pub enum Role { + #[sea_orm(string_value = "owner")] + Owner, + #[sea_orm(string_value = "admin")] + Admin, + #[sea_orm(string_value = "collaborator")] + Collaborator, +} diff --git a/entities/src/secondary_user.rs b/entities/src/secondary_user.rs new file mode 100644 index 00000000..9be26c73 --- /dev/null +++ b/entities/src/secondary_user.rs @@ -0,0 +1,36 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +use super::sea_orm_active_enums::Role; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "secondary_user")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub user_id: i64, + pub address: String, + pub description: String, + pub email: String, + pub role: Role, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::user::Entity", + from = "Column::UserId", + to = "super::user::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + User, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/entities/src/user.rs b/entities/src/user.rs new file mode 100644 index 00000000..64b50fe0 --- /dev/null +++ b/entities/src/user.rs @@ -0,0 +1,36 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "user")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + #[sea_orm(unique)] + pub address: String, + pub description: String, + pub email: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::secondary_user::Entity")] + SecondaryUser, + #[sea_orm(has_many = "super::user_keys::Entity")] + UserKeys, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SecondaryUser.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::UserKeys.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/entities/src/user_keys.rs b/entities/src/user_keys.rs new file mode 100644 index 00000000..2df86a89 --- /dev/null +++ b/entities/src/user_keys.rs @@ -0,0 +1,35 @@ +//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "user_keys")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i64, + pub user_id: i64, + pub api_key: String, + pub description: String, + pub private_txs: i8, + pub active: i8, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::user::Entity", + from = "Column::UserId", + to = "super::user::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + User, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::User.def() + } +} + +impl ActiveModelBehavior for ActiveModel {}