sea-orm/examples/basic/src/example_filling.rs
Billy Chan 4f8ad56cc4
Cont. Added support for using sea-orm with #[deny(missing_docs)] (#1531)
* Added support for using sea-orm with #[deny(missing_docs)] (#1522)

* feat(macros): Added documentation tags for generated entities

* chore: Added deny(missing_docs) attribute to basic example

* chore: Fix clippy errors

* ci: test missing docs of derive macros generated types

* Try missing docs (CI should fail)

* Revert "Try missing docs (CI should fail)"

This reverts commit 83356bfca8939e7807f14bad8bb816fcabc1bf7b.

---------

Co-authored-by: Lewin Probst, M.Sc <30552361+emirror-de@users.noreply.github.com>
2023-03-10 21:49:08 +08:00

80 lines
1.5 KiB
Rust

//! The `filling` entity.
use sea_orm::entity::prelude::*;
/// Filling entity
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
pub struct Entity;
impl EntityName for Entity {
fn table_name(&self) -> &str {
"filling"
}
}
/// Filling model
#[derive(Clone, Debug, PartialEq, Eq, DeriveModel, DeriveActiveModel)]
pub struct Model {
/// id field
pub id: i32,
/// name field
pub name: String,
}
/// Filling column
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
pub enum Column {
/// Id column
Id,
/// Name column
Name,
}
/// Filling primary key
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
pub enum PrimaryKey {
/// Id primary key
Id,
}
impl PrimaryKeyTrait for PrimaryKey {
type ValueType = i32;
fn auto_increment() -> bool {
true
}
}
/// Filling relation
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {}
impl ColumnTrait for Column {
type EntityName = Entity;
fn def(&self) -> ColumnDef {
match self {
Self::Id => ColumnType::Integer.def(),
Self::Name => ColumnType::String(None).def(),
}
}
}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
panic!()
}
}
impl Related<super::cake::Entity> for Entity {
fn to() -> RelationDef {
super::cake_filling::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cake_filling::Relation::Filling.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {}