use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "songs")] pub struct Model { #[sea_orm(primary_key)] #[serde(skip_deserializing)] pub id: i32, // Location on the filesystem path pub path: String, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm(has_one = "super::metadata::Entity")] Metadata, } // `Related` trait has to be implemented by hand impl Related for Entity { fn to() -> RelationDef { Relation::Metadata.def() } } impl ActiveModelBehavior for ActiveModel {}