93 lines
2.3 KiB
Rust
93 lines
2.3 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 {
|
|
"shipping_tax_rates"
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)]
|
|
pub struct Model {
|
|
pub shipping_option_id: String,
|
|
pub rate_id: String,
|
|
pub created_at: DateTimeWithTimeZone,
|
|
pub updated_at: DateTimeWithTimeZone,
|
|
pub metadata: Option<Json>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
|
pub enum Column {
|
|
ShippingOptionId,
|
|
RateId,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
Metadata,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
pub enum PrimaryKey {
|
|
ShippingOptionId,
|
|
RateId,
|
|
}
|
|
|
|
impl PrimaryKeyTrait for PrimaryKey {
|
|
type ValueType = (String, String);
|
|
fn auto_increment() -> bool {
|
|
false
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
pub enum Relation {
|
|
ShippingOptions,
|
|
TaxRates,
|
|
}
|
|
|
|
impl ColumnTrait for Column {
|
|
type EntityName = Entity;
|
|
fn def(&self) -> ColumnDef {
|
|
match self {
|
|
Self::ShippingOptionId => ColumnType::String(None).def(),
|
|
Self::RateId => ColumnType::String(None).def(),
|
|
Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(),
|
|
Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(),
|
|
Self::Metadata => ColumnType::JsonBinary.def().null(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RelationTrait for Relation {
|
|
fn def(&self) -> RelationDef {
|
|
match self {
|
|
Self::ShippingOptions => Entity::belongs_to(super::shipping_options::Entity)
|
|
.from(Column::ShippingOptionId)
|
|
.to(super::shipping_options::Column::Id)
|
|
.into(),
|
|
Self::TaxRates => Entity::belongs_to(super::tax_rates::Entity)
|
|
.from(Column::RateId)
|
|
.to(super::tax_rates::Column::Id)
|
|
.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Related<super::shipping_options::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::ShippingOptions.def()
|
|
}
|
|
}
|
|
|
|
impl Related<super::tax_rates::Entity> for Entity {
|
|
fn to() -> RelationDef {
|
|
Relation::TaxRates.def()
|
|
}
|
|
}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|