Skip to content

Commit

Permalink
Merge pull request #29 from kanko-travel/enhancement/ergonomic_input_…
Browse files Browse the repository at this point in the history
…types

made input types to relation constructors more ergonomic
  • Loading branch information
umran authored Sep 5, 2024
2 parents d87a62d + 111349b commit 17e133e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions model/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@ pub trait Model: Related {
}
}

fn belongs_to<R>(name: String, column: String) -> RelationDef
fn belongs_to<R>(name: &str, column: &str) -> RelationDef
where
Self: Sized,
R: Model,
{
RelationDef::belongs_to::<Self, R>(name, column)
RelationDef::belongs_to::<Self, R>(name.into(), column.into())
}

fn has_one<R>(name: String, column: String) -> RelationDef
fn has_one<R>(name: &str, column: &str) -> RelationDef
where
Self: Sized,
R: Model,
{
RelationDef::has_one::<Self, R>(name, column)
RelationDef::has_one::<Self, R>(name.into(), column.into())
}

fn has_many<R>(name: String, column: String) -> RelationDef
fn has_many<R>(name: &str, column: &str) -> RelationDef
where
Self: Sized,
R: Model,
{
RelationDef::has_many::<Self, R>(name, column)
RelationDef::has_many::<Self, R>(name.into(), column.into())
}

fn has_many_via<R>(name: String, junction_table_name: String) -> RelationDef
fn has_many_via<R>(name: &str, junction_table_name: &str) -> RelationDef
where
Self: Sized,
R: Model,
{
RelationDef::has_many_via::<Self, R>(name, junction_table_name)
RelationDef::has_many_via::<Self, R>(name.into(), junction_table_name.into())
}

fn id_field_value(&self) -> Uuid;
Expand Down

0 comments on commit 17e133e

Please sign in to comment.