2023-10-09 18:49:57 +00:00
|
|
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3
|
|
|
|
|
|
|
|
|
|
use sea_orm::entity::prelude::*;
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
|
|
|
|
#[sea_orm(table_name = "album")]
|
|
|
|
|
pub struct Model {
|
|
|
|
|
#[sea_orm(primary_key)]
|
|
|
|
|
pub id: i64,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub artist_id: Option<i64>,
|
2023-10-09 19:24:32 +00:00
|
|
|
pub cover_art_id: Option<i64>,
|
2023-10-09 18:49:57 +00:00
|
|
|
pub song_count: i32,
|
|
|
|
|
pub duration: i64,
|
|
|
|
|
pub play_count: i64,
|
2023-10-10 18:25:02 +00:00
|
|
|
pub created: TimeDateTimeWithTimeZone,
|
|
|
|
|
pub starred: Option<TimeDateTimeWithTimeZone>,
|
2023-10-09 18:49:57 +00:00
|
|
|
pub year: Option<i32>,
|
2023-10-10 18:25:02 +00:00
|
|
|
pub genre_ids: Option<Vec<i64>>,
|
|
|
|
|
pub played: TimeDateTimeWithTimeZone,
|
|
|
|
|
pub user_rating: Option<i16>,
|
|
|
|
|
pub artist_ids: Option<Vec<i64>>,
|
|
|
|
|
pub original_release_date: Option<TimeDateTimeWithTimeZone>,
|
|
|
|
|
pub music_folder_id: i64,
|
2023-10-09 18:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
|
|
|
pub enum Relation {
|
|
|
|
|
#[sea_orm(
|
|
|
|
|
belongs_to = "super::artist::Entity",
|
|
|
|
|
from = "Column::ArtistId",
|
|
|
|
|
to = "super::artist::Column::Id",
|
|
|
|
|
on_update = "NoAction",
|
|
|
|
|
on_delete = "SetNull"
|
|
|
|
|
)]
|
|
|
|
|
Artist,
|
2023-10-09 19:24:32 +00:00
|
|
|
#[sea_orm(
|
|
|
|
|
belongs_to = "super::cover_art::Entity",
|
|
|
|
|
from = "Column::CoverArtId",
|
|
|
|
|
to = "super::cover_art::Column::Id",
|
|
|
|
|
on_update = "NoAction",
|
|
|
|
|
on_delete = "SetNull"
|
|
|
|
|
)]
|
|
|
|
|
CoverArt,
|
2023-10-09 18:49:57 +00:00
|
|
|
#[sea_orm(
|
|
|
|
|
belongs_to = "super::music_folder::Entity",
|
|
|
|
|
from = "Column::MusicFolderId",
|
|
|
|
|
to = "super::music_folder::Column::Id",
|
|
|
|
|
on_update = "NoAction",
|
|
|
|
|
on_delete = "Cascade"
|
|
|
|
|
)]
|
|
|
|
|
MusicFolder,
|
2023-10-09 19:24:32 +00:00
|
|
|
#[sea_orm(has_many = "super::track::Entity")]
|
|
|
|
|
Track,
|
2023-10-09 18:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Related<super::artist::Entity> for Entity {
|
|
|
|
|
fn to() -> RelationDef {
|
|
|
|
|
Relation::Artist.def()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:24:32 +00:00
|
|
|
impl Related<super::cover_art::Entity> for Entity {
|
|
|
|
|
fn to() -> RelationDef {
|
|
|
|
|
Relation::CoverArt.def()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 18:49:57 +00:00
|
|
|
impl Related<super::music_folder::Entity> for Entity {
|
|
|
|
|
fn to() -> RelationDef {
|
|
|
|
|
Relation::MusicFolder.def()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:24:32 +00:00
|
|
|
impl Related<super::track::Entity> for Entity {
|
|
|
|
|
fn to() -> RelationDef {
|
|
|
|
|
Relation::Track.def()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 18:49:57 +00:00
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|