We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在gorm组件中,支持对PO层的tag进行index定义,以此实现索引的自动维护。 但当组合索引比较多时,此种方式不易阅读和后期的维护。 现增加一种新的方式: 在PO层,定义CreateIndex(),以此实现接口:
type IMigratorIndex interface { // CreateIndex 创建索引 CreateIndex() map[string][]string }
示例:
type AccountPO struct { Id int `gorm:"primaryKey;autoIncrement;comment:账户ID"` AccountName string `gorm:"size:32;not null;comment:账号名称"` } // 创建索引 func (*AccountPO) CreateIndex() map[string][]string { return map[string][]string{ "idx_name": {"account_name", "id"} } }
将在框架启动时,创建索引名称为:idx_name,字段为account_name、id 的组合索引。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在gorm组件中,支持对PO层的tag进行index定义,以此实现索引的自动维护。
但当组合索引比较多时,此种方式不易阅读和后期的维护。
现增加一种新的方式:
在PO层,定义CreateIndex(),以此实现接口:
示例:
将在框架启动时,创建索引名称为:idx_name,字段为account_name、id 的组合索引。
The text was updated successfully, but these errors were encountered: