//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "product_tags")]
pub struct Model {
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    #[sea_orm(primary_key)]
    pub id: i32,
    pub name: String,
    #[sea_orm(unique)]
    pub slug: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::product_product_tags::Entity")]
    ProductProductTags,
}

impl Related<super::product_product_tags::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::ProductProductTags.def()
    }
}

impl Related<super::products::Entity> for Entity {
    fn to() -> RelationDef {
        super::product_product_tags::Relation::Products.def()
    }
    fn via() -> Option<RelationDef> {
        Some(
            super::product_product_tags::Relation::ProductTags
                .def()
                .rev(),
        )
    }
}
