diff --git a/examples/cli/src/entity/cake.rs b/examples/cli/src/entity/cake.rs index 87ee5f1a..9b786a5f 100644 --- a/examples/cli/src/entity/cake.rs +++ b/examples/cli/src/entity/cake.rs @@ -53,14 +53,8 @@ impl ColumnTrait for Column { impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { - Self::CakeFilling => Entity::has_many(super::cake_filling::Entity) - .from(Column::Id) - .to(super::cake_filling::Column::CakeId) - .into(), - Self::Fruit => Entity::has_many(super::fruit::Entity) - .from(Column::Id) - .to(super::fruit::Column::CakeId) - .into(), + Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(), + Self::Fruit => Entity::has_many(super::fruit::Entity).into(), } } } diff --git a/examples/cli/src/entity/cake_filling.rs b/examples/cli/src/entity/cake_filling.rs index b35279d4..d5b4b8b6 100644 --- a/examples/cli/src/entity/cake_filling.rs +++ b/examples/cli/src/entity/cake_filling.rs @@ -54,11 +54,11 @@ impl ColumnTrait for Column { impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { - Self::Cake => Entity::has_one(super::cake::Entity) + Self::Cake => Entity::belongs_to(super::cake::Entity) .from(Column::CakeId) .to(super::cake::Column::Id) .into(), - Self::Filling => Entity::has_one(super::filling::Entity) + Self::Filling => Entity::belongs_to(super::filling::Entity) .from(Column::FillingId) .to(super::filling::Column::Id) .into(), diff --git a/examples/cli/src/entity/filling.rs b/examples/cli/src/entity/filling.rs index 4134652f..e4563e55 100644 --- a/examples/cli/src/entity/filling.rs +++ b/examples/cli/src/entity/filling.rs @@ -52,10 +52,7 @@ impl ColumnTrait for Column { impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { - Self::CakeFilling => Entity::has_many(super::cake_filling::Entity) - .from(Column::Id) - .to(super::cake_filling::Column::FillingId) - .into(), + Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(), } } } diff --git a/examples/cli/src/entity/fruit.rs b/examples/cli/src/entity/fruit.rs index c9b6d27a..f65d5b38 100644 --- a/examples/cli/src/entity/fruit.rs +++ b/examples/cli/src/entity/fruit.rs @@ -39,7 +39,6 @@ impl PrimaryKeyTrait for PrimaryKey { #[derive(Copy, Clone, Debug, EnumIter)] pub enum Relation { Cake, - Vendor, } impl ColumnTrait for Column { @@ -56,14 +55,10 @@ impl ColumnTrait for Column { impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { - Self::Cake => Entity::has_one(super::cake::Entity) + Self::Cake => Entity::belongs_to(super::cake::Entity) .from(Column::CakeId) .to(super::cake::Column::Id) .into(), - Self::Vendor => Entity::has_many(super::vendor::Entity) - .from(Column::Id) - .to(super::vendor::Column::FruitId) - .into(), } } } @@ -74,19 +69,10 @@ impl Related for Entity { } } -impl Related for Entity { - fn to() -> RelationDef { - Relation::Vendor.def() - } -} - impl Model { pub fn find_cake(&self) -> Select { Entity::find_related().belongs_to::(self) } - pub fn find_vendor(&self) -> Select { - Entity::find_related().belongs_to::(self) - } } impl ActiveModelBehavior for ActiveModel {} diff --git a/examples/cli/src/entity/mod.rs b/examples/cli/src/entity/mod.rs index 395d29f9..006f7e80 100644 --- a/examples/cli/src/entity/mod.rs +++ b/examples/cli/src/entity/mod.rs @@ -4,4 +4,3 @@ pub mod cake; pub mod cake_filling; pub mod filling; pub mod fruit; -pub mod vendor; diff --git a/examples/cli/src/entity/prelude.rs b/examples/cli/src/entity/prelude.rs index b4e85c78..b4c1c94f 100644 --- a/examples/cli/src/entity/prelude.rs +++ b/examples/cli/src/entity/prelude.rs @@ -4,4 +4,3 @@ pub use super::cake::Entity as Cake; pub use super::cake_filling::Entity as CakeFilling; pub use super::filling::Entity as Filling; pub use super::fruit::Entity as Fruit; -pub use super::vendor::Entity as Vendor;