Update generated examples
This commit is contained in:
parent
c36b94592d
commit
0afd226dbe
@ -53,14 +53,8 @@ impl ColumnTrait for Column {
|
|||||||
impl RelationTrait for Relation {
|
impl RelationTrait for Relation {
|
||||||
fn def(&self) -> RelationDef {
|
fn def(&self) -> RelationDef {
|
||||||
match self {
|
match self {
|
||||||
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity)
|
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(),
|
||||||
.from(Column::Id)
|
Self::Fruit => Entity::has_many(super::fruit::Entity).into(),
|
||||||
.to(super::cake_filling::Column::CakeId)
|
|
||||||
.into(),
|
|
||||||
Self::Fruit => Entity::has_many(super::fruit::Entity)
|
|
||||||
.from(Column::Id)
|
|
||||||
.to(super::fruit::Column::CakeId)
|
|
||||||
.into(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ impl ColumnTrait for Column {
|
|||||||
impl RelationTrait for Relation {
|
impl RelationTrait for Relation {
|
||||||
fn def(&self) -> RelationDef {
|
fn def(&self) -> RelationDef {
|
||||||
match self {
|
match self {
|
||||||
Self::Cake => Entity::has_one(super::cake::Entity)
|
Self::Cake => Entity::belongs_to(super::cake::Entity)
|
||||||
.from(Column::CakeId)
|
.from(Column::CakeId)
|
||||||
.to(super::cake::Column::Id)
|
.to(super::cake::Column::Id)
|
||||||
.into(),
|
.into(),
|
||||||
Self::Filling => Entity::has_one(super::filling::Entity)
|
Self::Filling => Entity::belongs_to(super::filling::Entity)
|
||||||
.from(Column::FillingId)
|
.from(Column::FillingId)
|
||||||
.to(super::filling::Column::Id)
|
.to(super::filling::Column::Id)
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -52,10 +52,7 @@ impl ColumnTrait for Column {
|
|||||||
impl RelationTrait for Relation {
|
impl RelationTrait for Relation {
|
||||||
fn def(&self) -> RelationDef {
|
fn def(&self) -> RelationDef {
|
||||||
match self {
|
match self {
|
||||||
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity)
|
Self::CakeFilling => Entity::has_many(super::cake_filling::Entity).into(),
|
||||||
.from(Column::Id)
|
|
||||||
.to(super::cake_filling::Column::FillingId)
|
|
||||||
.into(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ impl PrimaryKeyTrait for PrimaryKey {
|
|||||||
#[derive(Copy, Clone, Debug, EnumIter)]
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
Cake,
|
Cake,
|
||||||
Vendor,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ColumnTrait for Column {
|
impl ColumnTrait for Column {
|
||||||
@ -56,14 +55,10 @@ impl ColumnTrait for Column {
|
|||||||
impl RelationTrait for Relation {
|
impl RelationTrait for Relation {
|
||||||
fn def(&self) -> RelationDef {
|
fn def(&self) -> RelationDef {
|
||||||
match self {
|
match self {
|
||||||
Self::Cake => Entity::has_one(super::cake::Entity)
|
Self::Cake => Entity::belongs_to(super::cake::Entity)
|
||||||
.from(Column::CakeId)
|
.from(Column::CakeId)
|
||||||
.to(super::cake::Column::Id)
|
.to(super::cake::Column::Id)
|
||||||
.into(),
|
.into(),
|
||||||
Self::Vendor => Entity::has_many(super::vendor::Entity)
|
|
||||||
.from(Column::Id)
|
|
||||||
.to(super::vendor::Column::FruitId)
|
|
||||||
.into(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,19 +69,10 @@ impl Related<super::cake::Entity> for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Related<super::vendor::Entity> for Entity {
|
|
||||||
fn to() -> RelationDef {
|
|
||||||
Relation::Vendor.def()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Model {
|
impl Model {
|
||||||
pub fn find_cake(&self) -> Select<super::cake::Entity> {
|
pub fn find_cake(&self) -> Select<super::cake::Entity> {
|
||||||
Entity::find_related().belongs_to::<Entity>(self)
|
Entity::find_related().belongs_to::<Entity>(self)
|
||||||
}
|
}
|
||||||
pub fn find_vendor(&self) -> Select<super::vendor::Entity> {
|
|
||||||
Entity::find_related().belongs_to::<Entity>(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
@ -4,4 +4,3 @@ pub mod cake;
|
|||||||
pub mod cake_filling;
|
pub mod cake_filling;
|
||||||
pub mod filling;
|
pub mod filling;
|
||||||
pub mod fruit;
|
pub mod fruit;
|
||||||
pub mod vendor;
|
|
||||||
|
@ -4,4 +4,3 @@ pub use super::cake::Entity as Cake;
|
|||||||
pub use super::cake_filling::Entity as CakeFilling;
|
pub use super::cake_filling::Entity as CakeFilling;
|
||||||
pub use super::filling::Entity as Filling;
|
pub use super::filling::Entity as Filling;
|
||||||
pub use super::fruit::Entity as Fruit;
|
pub use super::fruit::Entity as Fruit;
|
||||||
pub use super::vendor::Entity as Vendor;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user