-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom table names like user1, user2,user... , They all have same columns, but table name #782
Comments
Hey @langzime, welcome! If I understand your question correctly: macro_rules! def_entity {
($mod: ident, $table_name: literal) => {
pub mod $mod {
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = $table_name)]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
}
};
}
def_entity!(user, "user");
def_entity!(user1, "user1");
def_entity!(user2, "user2"); You can create a macro your own to define those entities with ease. |
but it adds a lot of repetition, |
I have 256 tables and other 128 tables |
Motivation
Proposed Solutions
Additional Information
The text was updated successfully, but these errors were encountered: