cardamon/entities/
cpu.rs

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
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "cpu")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub name: String,
    #[sea_orm(column_type = "Float", nullable)]
    pub tdp: Option<f32>,
    pub power_curve_id: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::power_curve::Entity",
        from = "Column::PowerCurveId",
        to = "super::power_curve::Column::Id",
        on_update = "NoAction",
        on_delete = "NoAction"
    )]
    PowerCurve,
    #[sea_orm(has_many = "super::run::Entity")]
    Run,
}

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

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

impl ActiveModelBehavior for ActiveModel {}