Expand description
§Tardis-Macros
Tardis-Macros is a macro support library for the Tardis framework, providing additional macros to simplify code generation for DTO (Data Transfer Object) with sea_orm.
§Main Macros
TardisCreateEntity
: Generates code to create entities, combiningTardisCreateIndex
andTardisCreateTable
.
§Features
Tardis-Macros supports the following features, which enable the usage of specific macros:
Feature | Macro |
---|---|
reldb-postgres orreldb-mysql orreldb-sqlite | TardisCreateTable |
reldb-postgres orreldb-mysql orreldb-sqlite | TardisCreateIndex |
reldb-postgres orreldb-mysql orreldb-sqlite | TardisCreateEntity |
reldb-postgres orreldb-mysql orreldb-sqlite | TardisEmptyBehavior |
reldb-postgres orreldb-mysql orreldb-sqlite | TardisEmptyRelation |
Please note that the availability of each macro depends on the enabled features. Make sure to enable the corresponding feature to use the desired macro.
§How to Use
§Best Practices
Add the TardisCreateEntity
macro to your struct definition, along with other necessary derive macros like DeriveEntityModel
, TardisEmptyBehavior
, and TardisEmptyRelation
.
Example usage:
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, TardisCreateEntity, TardisEmptyBehavior, TardisEmptyRelation)]
#[sea_orm(table_name = "examples")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[index]
#[fill_ctx(own_paths)]
pub aaa: String,
}
You also can refer to the example code and test cases for the best practices on using the Tardis-Macros library.
For more examples and detailed usage, please refer to the documentation of each specific macro.
Derive Macros§
- Tardis
Create Entity - TardisCreateEntity
- Tardis
Create Index - TardisCreateIndex
- Tardis
Create Table - TardisCreateTable
- Tardis
Empty Behavior - TardisEmptyBehavior
- Tardis
Empty Relation - #TardisEmptyRelation
Generates an empty
Relation
.