toggl-portal/src/entity/time_entry.rs

44 lines
1.2 KiB
Rust

//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "time_entry")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub toggl_id: i64,
pub description: String,
pub project_id: Option<i64>,
pub start: DateTimeWithTimeZone,
pub stop: DateTimeWithTimeZone,
#[sea_orm(column_type = "JsonBinary")]
pub raw_json: Json,
#[sea_orm(column_type = "JsonBinary")]
pub tags: Json,
pub server_updated_at: DateTimeWithTimeZone,
pub server_deleted_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::project::Entity",
from = "Column::ProjectId",
to = "super::project::Column::TogglId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Project,
}
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::Project.def()
}
}
impl ActiveModelBehavior for ActiveModel {}