flix_db/entity/info/
shows.rs

1//! Show entity
2
3use flix_model::id::ShowId;
4
5use chrono::NaiveDate;
6use sea_orm::{
7	ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
8	EnumIter, PrimaryKeyTrait, Related, RelationDef, RelationTrait,
9};
10
11/// The database representation of a flix show
12#[derive(Debug, Clone, DeriveEntityModel)]
13#[sea_orm(table_name = "flix_info_shows")]
14pub struct Model {
15	/// The show's ID
16	#[sea_orm(primary_key, auto_increment = false)]
17	pub id: ShowId,
18	/// The show's title
19	pub title: String,
20	/// The show's tagline
21	pub tagline: String,
22	/// The show's overview
23	pub overview: String,
24	/// The show's air date
25	pub date: NaiveDate,
26}
27
28impl ActiveModelBehavior for ActiveModel {}
29
30/// Relation
31#[derive(Debug, EnumIter, DeriveRelation)]
32pub enum Relation {
33	/// The seasons that are part of this show
34	#[sea_orm(has_many = "super::seasons::Entity")]
35	Seasons,
36	/// The episodes that are part of this show
37	#[sea_orm(has_many = "super::episodes::Entity")]
38	Episodes,
39}
40
41impl Related<super::seasons::Entity> for Entity {
42	fn to() -> RelationDef {
43		Relation::Seasons.def()
44	}
45}
46
47impl Related<super::episodes::Entity> for Entity {
48	fn to() -> RelationDef {
49		Relation::Episodes.def()
50	}
51}