#[derive(TableEntity)]
{
// Attributes available to this derive:
#[table]
#[entity]
}
Expand description
为 struct 派生 TableEntity 实现,同时生成对应的 <Name>Field 和 <Name>Where 枚举。
§必填属性
#[table(name = "...")]:数据库表名。- 至少一个字段标注
#[entity(primary_key)]。
§可选表级属性
#[table(display_name = "...")]:展示名,默认同表名。#[table(soft_delete = "...")]:软删除字段名(当前版本保留,暂不展开生成)。
§可选字段级属性(#[entity(...)])
primary_key:标记主键字段(必须有且仅有一个)。max_length = <n>:字符串字段最大长度(默认 255)。unique:在 TableConfig 中添加该字段的唯一索引。required = true/false:覆盖“非 Option 默认必填“的推断。column = "...": 指定列名(默认同字段名)。skip:跳过此字段,不出现在枚举和 TableConfig 中。