//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use super::sea_orm_active_enums::CartTypes; #[derive(Copy, Clone, Default, Debug, DeriveEntity)] pub struct Entity; impl EntityName for Entity { fn table_name(&self) -> &str { "cart" } } #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] pub struct Model { pub id: String, pub email: Option, pub billing_address_id: Option, pub shipping_address_id: Option, pub region_id: String, pub customer_id: Option, pub payment_id: Option, pub r#type: CartTypes, pub completed_at: Option, pub created_at: DateTimeWithTimeZone, pub updated_at: DateTimeWithTimeZone, pub deleted_at: Option, pub metadata: Option, pub idempotency_key: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] pub enum Column { Id, Email, BillingAddressId, ShippingAddressId, RegionId, CustomerId, PaymentId, Type, CompletedAt, CreatedAt, UpdatedAt, DeletedAt, Metadata, IdempotencyKey, } #[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] pub enum PrimaryKey { Id, } impl PrimaryKeyTrait for PrimaryKey { type ValueType = String; fn auto_increment() -> bool { false } } #[derive(Copy, Clone, Debug, EnumIter)] pub enum Relation { Addresses2, Addresses1, Customers, LineItems, Order, PaymentSessions, Payments, Regions, ShippingMethods, Swap, } impl ColumnTrait for Column { type EntityName = Entity; fn def(&self) -> ColumnDef { match self { Self::Id => ColumnType::String(None).def(), Self::Email => ColumnType::String(None).def().null(), Self::BillingAddressId => ColumnType::String(None).def().null(), Self::ShippingAddressId => ColumnType::String(None).def().null(), Self::RegionId => ColumnType::String(None).def(), Self::CustomerId => ColumnType::String(None).def().null(), Self::PaymentId => ColumnType::String(None).def().null().unique(), Self::Type => CartTypes::db_type().def(), Self::CompletedAt => ColumnType::TimestampWithTimeZone.def().null(), Self::CreatedAt => ColumnType::TimestampWithTimeZone.def(), Self::UpdatedAt => ColumnType::TimestampWithTimeZone.def(), Self::DeletedAt => ColumnType::TimestampWithTimeZone.def().null(), Self::Metadata => ColumnType::JsonBinary.def().null(), Self::IdempotencyKey => ColumnType::String(None).def().null(), } } } impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { Self::Addresses2 => Entity::belongs_to(super::addresses::Entity) .from(Column::BillingAddressId) .to(super::addresses::Column::Id) .into(), Self::Addresses1 => Entity::belongs_to(super::addresses::Entity) .from(Column::ShippingAddressId) .to(super::addresses::Column::Id) .into(), Self::Customers => Entity::belongs_to(super::customers::Entity) .from(Column::CustomerId) .to(super::customers::Column::Id) .into(), Self::LineItems => Entity::has_many(super::line_items::Entity).into(), Self::Order => Entity::has_one(super::order::Entity).into(), Self::PaymentSessions => Entity::has_many(super::payment_sessions::Entity).into(), Self::Payments => Entity::belongs_to(super::payments::Entity) .from(Column::PaymentId) .to(super::payments::Column::Id) .into(), Self::Regions => Entity::belongs_to(super::regions::Entity) .from(Column::RegionId) .to(super::regions::Column::Id) .into(), Self::ShippingMethods => Entity::has_many(super::shipping_methods::Entity).into(), Self::Swap => Entity::has_one(super::swap::Entity).into(), } } } impl Related for Entity { fn to() -> RelationDef { Relation::Customers.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::LineItems.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Order.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::PaymentSessions.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Payments.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Regions.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::ShippingMethods.def() } } impl Related for Entity { fn to() -> RelationDef { Relation::Swap.def() } } impl Related for Entity { fn to() -> RelationDef { super::cart_discounts::Relation::Discounts.def() } fn via() -> Option { Some(super::cart_discounts::Relation::Cart.def().rev()) } } impl Related for Entity { fn to() -> RelationDef { super::cart_gift_cards::Relation::GiftCards.def() } fn via() -> Option { Some(super::cart_gift_cards::Relation::Cart.def().rev()) } } impl ActiveModelBehavior for ActiveModel {}