siteslib/jsonb/
comments.rsuse chrono::{NaiveDateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Comments {
pub id: Option<Uuid>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
pub data: Option<NaiveDateTime>,
}
impl Comments {
pub fn normalize(&self) -> Self {
Self {
id: Option::from(if self.id.is_none() {
Uuid::new_v4()
} else {
self.id.unwrap()
}),
comment: self.comment.clone(),
data: Option::from(Utc::now().naive_local())
}
}
}