Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "artists")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
#[sea_orm(nullable)]
|
||||
pub musicbrainz_id: Option<String>,
|
||||
pub added_at: chrono::NaiveDateTime,
|
||||
/// JSON-serialized Vec of top song info
|
||||
pub top_songs: String,
|
||||
/// JSON-serialized Vec of similar artist info
|
||||
pub similar_artists: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::album::Entity")]
|
||||
Albums,
|
||||
#[sea_orm(has_many = "super::track::Entity")]
|
||||
Tracks,
|
||||
#[sea_orm(has_many = "super::wanted_item::Entity")]
|
||||
WantedItems,
|
||||
}
|
||||
|
||||
impl Related<super::album::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Albums.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::track::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Tracks.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::wanted_item::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::WantedItems.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user