84 lines
1.9 KiB
Rust
84 lines
1.9 KiB
Rust
|
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
|
||
|
|
||
|
use sea_orm::entity::prelude::*;
|
||
|
use serde::{Deserialize, Serialize};
|
||
|
|
||
|
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
||
|
pub struct Entity;
|
||
|
|
||
|
impl EntityName for Entity {
|
||
|
fn table_name(&self) -> &str {
|
||
|
"cart_discounts"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)]
|
||
|
pub struct Model {
|
||
|
pub cart_id: String,
|
||
|
pub discount_id: String,
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||
|
pub enum Column {
|
||
|
CartId,
|
||
|
DiscountId,
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
||
|
pub enum PrimaryKey {
|
||
|
CartId,
|
||
|
DiscountId,
|
||
|
}
|
||
|
|
||
|
impl PrimaryKeyTrait for PrimaryKey {
|
||
|
type ValueType = (String, String);
|
||
|
fn auto_increment() -> bool {
|
||
|
false
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||
|
pub enum Relation {
|
||
|
Carts,
|
||
|
Discounts,
|
||
|
}
|
||
|
|
||
|
impl ColumnTrait for Column {
|
||
|
type EntityName = Entity;
|
||
|
fn def(&self) -> ColumnDef {
|
||
|
match self {
|
||
|
Self::CartId => ColumnType::String(None).def(),
|
||
|
Self::DiscountId => ColumnType::String(None).def(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl RelationTrait for Relation {
|
||
|
fn def(&self) -> RelationDef {
|
||
|
match self {
|
||
|
Self::Carts => Entity::belongs_to(super::carts::Entity)
|
||
|
.from(Column::CartId)
|
||
|
.to(super::carts::Column::Id)
|
||
|
.into(),
|
||
|
Self::Discounts => Entity::belongs_to(super::discounts::Entity)
|
||
|
.from(Column::DiscountId)
|
||
|
.to(super::discounts::Column::Id)
|
||
|
.into(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Related<super::carts::Entity> for Entity {
|
||
|
fn to() -> RelationDef {
|
||
|
Relation::Carts.def()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Related<super::discounts::Entity> for Entity {
|
||
|
fn to() -> RelationDef {
|
||
|
Relation::Discounts.def()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl ActiveModelBehavior for ActiveModel {}
|