//! `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_product_tags")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub product_id: i32,
    #[sea_orm(primary_key, auto_increment = false)]
    pub product_tag_id: i32,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::product_tags::Entity",
        from = "Column::ProductTagId",
        to = "super::product_tags::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    ProductTags,
    #[sea_orm(
        belongs_to = "super::products::Entity",
        from = "Column::ProductId",
        to = "super::products::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    Products,
}

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

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