pub trait BelongsTo<P>:
Entity
+ Clone
+ Send
+ Sync{
// Required methods
fn foreign_key() -> &'static str;
fn foreign_key_value(&self) -> Option<String>;
// Provided method
fn relation_meta() -> RelationMeta { ... }
}Expand description
Trait for BelongsTo relationships (child-to-parent)
A BelongsTo relationship exists when the child entity contains a foreign key that references the parent entity.
§Example
use ormkit::relations::BelongsTo;
// Post belongs to User
impl BelongsTo<User> for Post {
fn foreign_key() -> &'static str {
"user_id"
}
}Required Methods§
Sourcefn foreign_key() -> &'static str
fn foreign_key() -> &'static str
The foreign key column name on this entity
This is the column that stores the ID of the parent entity
Sourcefn foreign_key_value(&self) -> Option<String>
fn foreign_key_value(&self) -> Option<String>
Provided Methods§
Sourcefn relation_meta() -> RelationMeta
fn relation_meta() -> RelationMeta
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.