Use find_related in place of find_xxx

This commit is contained in:
Sam Samai 2021-06-29 12:03:11 +10:00
parent 59322d37d8
commit 8f66968724
6 changed files with 10 additions and 30 deletions

View File

@ -68,4 +68,14 @@ impl Related<super::bakery::Entity> for Entity {
}
}
impl Related<super::cake::Entity> for Entity {
fn to() -> RelationDef {
super::cakes_bakers::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cakes_bakers::Relation::Baker.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -67,10 +67,4 @@ impl Related<super::baker::Entity> for Entity {
}
}
impl Model {
pub fn find_bakers(&self) -> Select<super::baker::Entity> {
Entity::find_related().belongs_to::<Entity>(self)
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -98,10 +98,4 @@ impl Related<super::baker::Entity> for Entity {
}
}
impl Model {
pub fn find_bakers(&self) -> Select<super::baker::Entity> {
Entity::find_related().belongs_to::<Entity>(self)
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -68,10 +68,4 @@ impl Related<super::order::Entity> for Entity {
}
}
impl Model {
pub fn find_orders(&self) -> Select<super::order::Entity> {
Entity::find_related().belongs_to::<Entity>(self)
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -71,10 +71,4 @@ impl Related<super::order::Entity> for Entity {
}
}
impl Model {
pub fn find_orders(&self) -> Select<super::order::Entity> {
Entity::find_related().belongs_to::<Entity>(self)
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@ -93,10 +93,4 @@ impl Related<super::lineitem::Entity> for Entity {
}
}
impl Model {
pub fn find_lineitems(&self) -> Select<super::lineitem::Entity> {
Entity::find_related().belongs_to::<Entity>(self)
}
}
impl ActiveModelBehavior for ActiveModel {}