webfingerd/src/entity/resources.rs

42 lines
1 KiB
Rust
Raw Normal View History

use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "resources")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub domain_id: String,
#[sea_orm(unique)]
pub resource_uri: String,
pub aliases: Option<String>,
pub properties: Option<String>,
pub created_at: chrono::NaiveDateTime,
pub updated_at: chrono::NaiveDateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::domains::Entity",
from = "Column::DomainId",
to = "super::domains::Column::Id"
)]
Domain,
#[sea_orm(has_many = "super::links::Entity")]
Links,
}
impl Related<super::domains::Entity> for Entity {
fn to() -> RelationDef {
Relation::Domain.def()
}
}
impl Related<super::links::Entity> for Entity {
fn to() -> RelationDef {
Relation::Links.def()
}
}
impl ActiveModelBehavior for ActiveModel {}