pub struct AuditMetadata {
pub created_at: Option<DateTime<Utc>>,
pub updated_at: Option<DateTime<Utc>>,
pub deleted_at: Option<DateTime<Utc>>,
pub created_by: Option<Uuid>,
pub updated_by: Option<Uuid>,
pub deleted_by: Option<Uuid>,
}Expand description
Audit metadata stored as JSONB in the database
This struct consolidates audit fields (timestamps and actors) into a single JSONB column for efficient storage and flexible querying.
Fields§
§created_at: Option<DateTime<Utc>>Timestamp when the record was created
updated_at: Option<DateTime<Utc>>Timestamp when the record was last updated
deleted_at: Option<DateTime<Utc>>Timestamp when the record was soft-deleted
created_by: Option<Uuid>User ID who created the record
updated_by: Option<Uuid>User ID who last updated the record
deleted_by: Option<Uuid>User ID who deleted the record
Implementations§
Source§impl AuditMetadata
impl AuditMetadata
Sourcepub fn with_creator(creator_id: Uuid) -> Self
pub fn with_creator(creator_id: Uuid) -> Self
Create with creator ID
Sourcepub fn soft_delete(&mut self)
pub fn soft_delete(&mut self)
Soft delete the record
Sourcepub fn soft_delete_by(&mut self, deleter_id: Uuid)
pub fn soft_delete_by(&mut self, deleter_id: Uuid)
Soft delete with deleter ID
Sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Check if record is deleted
Trait Implementations§
Source§impl Clone for AuditMetadata
impl Clone for AuditMetadata
Source§impl Debug for AuditMetadata
impl Debug for AuditMetadata
Source§impl Default for AuditMetadata
impl Default for AuditMetadata
Source§impl<'de> Deserialize<'de> for AuditMetadata
impl<'de> Deserialize<'de> for AuditMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AuditMetadata
impl PartialEq for AuditMetadata
Source§impl Serialize for AuditMetadata
impl Serialize for AuditMetadata
impl StructuralPartialEq for AuditMetadata
Auto Trait Implementations§
impl Freeze for AuditMetadata
impl RefUnwindSafe for AuditMetadata
impl Send for AuditMetadata
impl Sync for AuditMetadata
impl Unpin for AuditMetadata
impl UnsafeUnpin for AuditMetadata
impl UnwindSafe for AuditMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more