use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "album")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: String,
pub title: String,
pub artist: String,
pub artist_id: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::track::Entity")]
Track,
#[sea_orm(
belongs_to = "super::artist::Entity",
from = "Column::ArtistId",
to = "super::artist::Column::Id"
)]
Artist,
}
impl Related<super::track::Entity> for Entity {
fn to() -> RelationDef {
Relation::Track.def()
}
}
impl Related<super::artist::Entity> for Entity {
fn to() -> RelationDef {
Relation::Artist.def()
}
}
impl ActiveModelBehavior for ActiveModel {}