diff --git a/backend/src/entity/tag.rs b/backend/src/entity/tag.rs new file mode 100644 index 0000000..ca5cf90 --- /dev/null +++ b/backend/src/entity/tag.rs @@ -0,0 +1,36 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 + +use super::*; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "tag")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + #[sea_orm(unique)] + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::tag_problem::Entity")] + TagProblem, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::TagProblem.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + tag_problem::Relation::Problem.def() + } + fn via() -> Option { + Some(tag_problem::Relation::Tag.def().rev()) + } +} + +impl ActiveModelBehavior for ActiveModel {}