58 lines
1.5 KiB
Rust
58 lines
1.5 KiB
Rust
|
|
//! `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: Option<String>,
|
||
|
|
pub artist_id: Option<i64>,
|
||
|
|
pub cover_art: Option<String>,
|
||
|
|
pub song_count: i32,
|
||
|
|
pub duration: i64,
|
||
|
|
pub play_count: i64,
|
||
|
|
pub created: DateTimeWithTimeZone,
|
||
|
|
pub starred: Option<DateTimeWithTimeZone>,
|
||
|
|
pub year: Option<i32>,
|
||
|
|
pub genre: Option<String>,
|
||
|
|
pub music_folder_id: Option<i64>,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[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,
|
||
|
|
#[sea_orm(
|
||
|
|
belongs_to = "super::music_folder::Entity",
|
||
|
|
from = "Column::MusicFolderId",
|
||
|
|
to = "super::music_folder::Column::Id",
|
||
|
|
on_update = "NoAction",
|
||
|
|
on_delete = "Cascade"
|
||
|
|
)]
|
||
|
|
MusicFolder,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Related<super::artist::Entity> for Entity {
|
||
|
|
fn to() -> RelationDef {
|
||
|
|
Relation::Artist.def()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Related<super::music_folder::Entity> for Entity {
|
||
|
|
fn to() -> RelationDef {
|
||
|
|
Relation::MusicFolder.def()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl ActiveModelBehavior for ActiveModel {}
|