use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "news")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub source: Uuid,
#[sea_orm(column_type = "Text", nullable)]
pub source_provided_id: Option<String>,
pub is_latest_version: bool,
pub previous_version: Option<Uuid>,
#[sea_orm(column_type = "Text", nullable)]
pub uri: Option<String>,
#[sea_orm(column_type = "Text")]
pub title: String,
#[sea_orm(column_type = "Text", nullable)]
pub summary: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub content: Option<String>,
pub published_at: Option<TimeDateTimeWithTimeZone>,
pub updated_at: Option<TimeDateTimeWithTimeZone>,
pub first_fetched_at: TimeDateTimeWithTimeZone,
pub last_fetched_at: TimeDateTimeWithTimeZone,
pub is_read: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::PreviousVersion",
to = "Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(has_many = "super::news_apearance_signal::Entity")]
NewsApearanceSignal,
#[sea_orm(has_many = "super::news_explicit_vote_signal::Entity")]
NewsExplicitVoteSignal,
#[sea_orm(has_many = "super::news_focus_signal::Entity")]
NewsFocusSignal,
#[sea_orm(has_many = "super::news_read_signal::Entity")]
NewsReadSignal,
#[sea_orm(has_many = "super::news_to_label_link::Entity")]
NewsToLabelLink,
#[sea_orm(
belongs_to = "super::source::Entity",
from = "Column::Source",
to = "super::source::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Source,
}
impl Related<super::news_apearance_signal::Entity> for Entity {
fn to() -> RelationDef {
Relation::NewsApearanceSignal.def()
}
}
impl Related<super::news_explicit_vote_signal::Entity> for Entity {
fn to() -> RelationDef {
Relation::NewsExplicitVoteSignal.def()
}
}
impl Related<super::news_focus_signal::Entity> for Entity {
fn to() -> RelationDef {
Relation::NewsFocusSignal.def()
}
}
impl Related<super::news_read_signal::Entity> for Entity {
fn to() -> RelationDef {
Relation::NewsReadSignal.def()
}
}
impl Related<super::news_to_label_link::Entity> for Entity {
fn to() -> RelationDef {
Relation::NewsToLabelLink.def()
}
}
impl Related<super::source::Entity> for Entity {
fn to() -> RelationDef {
Relation::Source.def()
}
}
impl Related<super::news_label::Entity> for Entity {
fn to() -> RelationDef {
super::news_to_label_link::Relation::NewsLabel.def()
}
fn via() -> Option<RelationDef> {
Some(super::news_to_label_link::Relation::News.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {}