pub struct LinkEntity {
pub id: Uuid,
pub entity_type: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub deleted_at: Option<DateTime<Utc>>,
pub status: String,
pub tenant_id: Option<Uuid>,
pub link_type: String,
pub source_id: Uuid,
pub target_id: Uuid,
pub metadata: Option<Value>,
}Expand description
A polymorphic link between two entities
Links follow the Entity model with base fields (id, type, timestamps, status) plus relationship-specific fields (source_id, target_id, link_type).
Fields§
§id: UuidUnique identifier for this link
entity_type: StringEntity type (always “link” for base links)
created_at: DateTime<Utc>When this link was created
updated_at: DateTime<Utc>When this link was last updated
deleted_at: Option<DateTime<Utc>>When this link was soft-deleted (if applicable)
status: StringStatus of the link
tenant_id: Option<Uuid>Optional tenant ID for multi-tenant isolation
When set, this link belongs to a specific tenant. When None, the link is treated as system-wide or single-tenant.
link_type: StringThe type of relationship (e.g., “owner”, “driver”, “worker”)
source_id: UuidThe ID of the source entity
target_id: UuidThe ID of the target entity
metadata: Option<Value>Optional metadata for the relationship
Implementations§
Source§impl LinkEntity
impl LinkEntity
Sourcepub fn new(
link_type: impl Into<String>,
source_id: Uuid,
target_id: Uuid,
metadata: Option<Value>,
) -> Self
pub fn new( link_type: impl Into<String>, source_id: Uuid, target_id: Uuid, metadata: Option<Value>, ) -> Self
Create a new link without tenant context
For multi-tenant applications, use new_with_tenant() instead.
Sourcepub fn new_with_tenant(
tenant_id: Uuid,
link_type: impl Into<String>,
source_id: Uuid,
target_id: Uuid,
metadata: Option<Value>,
) -> Self
pub fn new_with_tenant( tenant_id: Uuid, link_type: impl Into<String>, source_id: Uuid, target_id: Uuid, metadata: Option<Value>, ) -> Self
Create a new link with tenant context for multi-tenant applications
§Example
use uuid::Uuid;
use this::core::link::LinkEntity;
let tenant_id = Uuid::new_v4();
let link = LinkEntity::new_with_tenant(
tenant_id,
"has_invoice",
order_id,
invoice_id,
None,
);
assert_eq!(link.tenant_id, Some(tenant_id));Sourcepub fn soft_delete(&mut self)
pub fn soft_delete(&mut self)
Soft delete this link
Sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Check if the link is deleted
Trait Implementations§
Source§impl Clone for LinkEntity
impl Clone for LinkEntity
Source§fn clone(&self) -> LinkEntity
fn clone(&self) -> LinkEntity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more