starfish_core/entities/
entity.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
5#[sea_orm(table_name = "entity")]
6pub struct Model {
7    #[sea_orm(primary_key)]
8    pub id: i32,
9    #[sea_orm(unique, indexed)]
10    pub name: String,
11}
12
13#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
14pub enum Relation {
15    #[sea_orm(has_many = "super::entity_attribute::Entity")]
16    EntityAttribute,
17}
18
19impl Related<super::entity_attribute::Entity> for Entity {
20    fn to() -> RelationDef {
21        Relation::EntityAttribute.def()
22    }
23}
24
25#[derive(Debug)]
26pub struct DependencyLink;
27
28impl Linked for DependencyLink {
29    type FromEntity = Entity;
30
31    type ToEntity = Entity;
32
33    fn link(&self) -> Vec<RelationDef> {
34        vec![
35            super::relation::Relation::FromEntity.def(),
36            super::relation::Relation::ToEntity.def(),
37        ]
38    }
39}
40
41impl ActiveModelBehavior for ActiveModel {}