You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mediarepo/mediarepo-daemon/mediarepo-database/src/entities/file.rs

59 lines
1.3 KiB
Rust

use chrono::NaiveDateTime;
use sea_orm::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "files")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
pub file_type: u32,
pub name: Option<String>,
pub comment: Option<String>,
pub mime_type: Option<String>,
pub storage_id: i64,
pub hash_id: i64,
pub import_time: NaiveDateTime,
pub creation_time: NaiveDateTime,
pub change_time: NaiveDateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::hash::Entity",
from = "Column::HashId",
to = "super::hash::Column::Id"
)]
Hash,
#[sea_orm(
belongs_to = "super::storage::Entity",
from = "Column::StorageId",
to = "super::storage::Column::Id"
)]
Storage,
#[sea_orm(has_many = "super::thumbnail::Entity")]
Thumbnail,
}
impl Related<super::hash::Entity> for Entity {
fn to() -> RelationDef {
Relation::Hash.def()
}
}
impl Related<super::storage::Entity> for Entity {
fn to() -> RelationDef {
Relation::Storage.def()
}
}
impl Related<super::thumbnail::Entity> for Entity {
fn to() -> RelationDef {
Relation::Thumbnail.def()
}
}
impl ActiveModelBehavior for ActiveModel {}