Skip to content

Entity #538

Answered by billy1624
Ilqjx asked this question in Q&A
Feb 16, 2022 · 2 comments
Discussion options

You must be logged in to vote

Hey @Ilqjx, welcome! Good questions!

The DeriveEntityModel proc_macro actually defined Entity struct and implemented EntityName trait for you under the hood.

#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
pub struct Entity;

impl EntityName for Entity {
    fn schema_name(&self) -> Option<&str> {
        None
    }

    fn table_name(&self) -> &str {
        "cake"
    }
}

Adapted from https://www.sea-ql.org/SeaORM/docs/generate-entity/expanded-entity-structure#entity

The source code of DeriveEntityModel proc_macro:

quote! {
#[derive(Copy, Clone, Default, Debug, sea_orm::prelude::DeriveEntity)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by billy1624
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #536 on February 17, 2022 02:40.