use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "category_watches")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: Uuid,
pub category_id: Uuid,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(belongs_to = "super::users::Entity", from = "Column::UserId", to = "super::users::Column::Id", on_update = "Cascade", on_delete = "Cascade")]
Users,
#[sea_orm(belongs_to = "super::categories::Entity", from = "Column::CategoryId", to = "super::categories::Column::Id", on_update = "Cascade", on_delete = "Cascade")]
Categories,
}
impl Related<super::users::Entity> for Entity {
fn to() -> RelationDef {
Relation::Users.def()
}
}
impl Related<super::categories::Entity> for Entity {
fn to() -> RelationDef {
Relation::Categories.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.1 KiB · text
History
2264215