librmo/entity/
media.rs

1//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15
2
3use sea_orm::entity::prelude::*;
4use serde::Serialize;
5
6#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize)]
7#[sea_orm(table_name = "media")]
8pub struct Model {
9    #[sea_orm(primary_key)]
10    pub id: i32,
11    pub mtime: String,
12    #[sea_orm(unique)]
13    pub path: String,
14    pub file_type: String,
15    pub library_id: i32,
16}
17
18#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19pub enum Relation {
20    #[sea_orm(
21        belongs_to = "super::library::Entity",
22        from = "Column::LibraryId",
23        to = "super::library::Column::Id",
24        on_update = "NoAction",
25        on_delete = "Cascade"
26    )]
27    Library,
28    #[sea_orm(has_many = "super::music::Entity")]
29    Music,
30    #[sea_orm(has_many = "super::report::Entity")]
31    Report,
32}
33
34impl Related<super::report::Entity> for Entity {
35    fn to() -> RelationDef {
36        Relation::Report.def()
37    }
38}
39
40impl Related<super::library::Entity> for Entity {
41    fn to() -> RelationDef {
42        Relation::Library.def()
43    }
44}
45
46impl Related<super::music::Entity> for Entity {
47    fn to() -> RelationDef {
48        Relation::Music.def()
49    }
50}
51
52impl ActiveModelBehavior for ActiveModel {}