flix_db/entity/content/
libraries.rs1use flix_model::id::LibraryId;
4
5use seamantic::model::path::PathBytes;
6
7use sea_orm::{
8 ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
9 EnumIter, PrimaryKeyTrait, Related, RelationDef, RelationTrait,
10};
11
12#[derive(Debug, Clone, DeriveEntityModel)]
14#[sea_orm(table_name = "flix_libraries")]
15pub struct Model {
16 #[sea_orm(primary_key, auto_increment = false)]
18 pub id: LibraryId,
19 pub directory: PathBytes,
21}
22
23impl ActiveModelBehavior for ActiveModel {}
24
25#[derive(Debug, EnumIter, DeriveRelation)]
27pub enum Relation {
28 #[sea_orm(has_many = "super::collections::Entity")]
30 Collections,
31 #[sea_orm(has_many = "super::movies::Entity")]
32 Movies,
34 #[sea_orm(has_many = "super::shows::Entity")]
35 Shows,
37 #[sea_orm(has_many = "super::seasons::Entity")]
38 Seasons,
40 #[sea_orm(has_many = "super::episodes::Entity")]
41 Episodes,
43}
44
45impl Related<super::collections::Entity> for Entity {
46 fn to() -> RelationDef {
47 Relation::Collections.def()
48 }
49}
50
51impl Related<super::movies::Entity> for Entity {
52 fn to() -> RelationDef {
53 Relation::Movies.def()
54 }
55}
56
57impl Related<super::shows::Entity> for Entity {
58 fn to() -> RelationDef {
59 Relation::Shows.def()
60 }
61}
62
63impl Related<super::seasons::Entity> for Entity {
64 fn to() -> RelationDef {
65 Relation::Seasons.def()
66 }
67}
68
69impl Related<super::episodes::Entity> for Entity {
70 fn to() -> RelationDef {
71 Relation::Episodes.def()
72 }
73}