flix_db/entity/tmdb/
collections.rs1use flix_model::id::CollectionId as FlixId;
4use flix_tmdb::model::id::CollectionId;
5
6use chrono::NaiveDate;
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_tmdb_collections")]
15pub struct Model {
16 #[sea_orm(primary_key, auto_increment = false)]
18 pub tmdb_id: CollectionId,
19 pub flix_id: FlixId,
21 pub last_update: NaiveDate,
23 pub movie_count: u16,
25}
26
27impl ActiveModelBehavior for ActiveModel {}
28
29#[derive(Debug, EnumIter, DeriveRelation)]
31pub enum Relation {
32 #[sea_orm(has_many = "super::movies::Entity")]
34 Movies,
35}
36
37impl Related<super::movies::Entity> for Entity {
38 fn to() -> RelationDef {
39 Relation::Movies.def()
40 }
41}