GORM支持的全部标签

发布时间 2023-06-06 13:07:29作者: 李若盛开

column: 指定数据库中的字段名,例如:column:name。
type: 指定数据库中的字段类型,例如:type:varchar(255)。
size: 指定字段的大小,例如:size:255。
primaryKey: 指定该字段为主键,例如:primaryKey。
autoIncrement: 指定该字段自增,例如:autoIncrement。
default: 指定该字段的默认值,例如:default:0。
not null: 指定该字段为非空,例如:not null。
unique: 指定该字段为唯一,例如:unique。
index: 指定该字段需要建立索引,例如:index。
uniqueIndex: 指定该字段需要建立唯一索引,例如:uniqueIndex。
precision: 指定浮点数的精度,例如:precision:10。
scale: 指定浮点数的小数位数,例如:scale:2。
embedded: 指定该字段是嵌入式结构体,例如:embedded。
ignore: 指定该字段忽略,例如:ignore。
unique_index: 指定该字段需要建立唯一索引,例如:unique_index:idx_name_age。
foreignkey: 指定外键,例如:foreignkey:user_id。
assoc_foreignkey: 指定关联表的外键,例如:assoc_foreignkey:user_id。
association_foreignkey: 指定关联表的外键,例如:association_foreignkey:user_id。
association_autocreate: 指定自动创建关联表,例如:association_autocreate。
association_autoupdate: 指定自动更新关联表,例如:association_autoupdate。
association_autodelete: 指定自动删除关联表,例如:association_autodelete。
polymorphic: 指定多态关联,例如:polymorphic:value。
polymorphic_type: 指定多态类型,例如:polymorphic_type:payment。
polymorphic_value: 指定多态值,例如:polymorphic_value:credit_card。
many2many: 指定多对多关系,例如:many2many:products。
jointable_foreignkey: 指定多对多关系表的外键,例如:jointable_foreignkey:user_id。
association_jointable_foreignkey: 指定多对多关系表的外键,例如:association_jointable_foreignkey:user_id。
jointable: 指定多对多关系的关联表,例如:jointable:products_liked。
association_jointable: 指定多对多关系的关联表,例如:association_jointable:products_liked。