flix_db/entity/tmdb/
shows.rs

1//! Show entity
2
3use flix_model::id::ShowId as FlixId;
4use flix_tmdb::model::id::ShowId;
5
6use chrono::NaiveDate;
7use sea_orm::{
8	ActiveModelBehavior, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityTrait,
9	EnumIter, PrimaryKeyTrait, Related, RelationDef, RelationTrait,
10};
11
12/// The database representation of a tmdb show
13#[derive(Debug, Clone, DeriveEntityModel)]
14#[sea_orm(table_name = "flix_tmdb_shows")]
15pub struct Model {
16	/// The show's TMDB ID
17	#[sea_orm(primary_key, auto_increment = false)]
18	pub tmdb_id: ShowId,
19	/// The show's ID
20	pub flix_id: FlixId,
21	/// The movie's runtime in seconds
22	pub last_update: NaiveDate,
23	/// The number of seasons the show has
24	pub number_of_seasons: u32,
25}
26
27impl ActiveModelBehavior for ActiveModel {}
28
29/// Relation
30#[derive(Debug, EnumIter, DeriveRelation)]
31pub enum Relation {
32	/// The seasons that are part of this show
33	#[sea_orm(has_many = "super::seasons::Entity")]
34	Seasons,
35}
36
37impl Related<super::seasons::Entity> for Entity {
38	fn to() -> RelationDef {
39		Relation::Seasons.def()
40	}
41}