高级主题
复合主键
登录后可跨设备保存划线和私人笔记登录
将多个字段设置为主键会创建复合主键,例如:
type Product struct {
ID string `gorm:"primaryKey"`
LanguageCode string `gorm:"primaryKey"`
Code string
Name string
}注意 整数类型的 PrioritizedPrimaryField 默认启用 AutoIncrement,如需禁用,需要关闭整数字段的 autoIncrement:
type Product struct {
CategoryID uint64 `gorm:"primaryKey;autoIncrement:false"`
TypeID uint64 `gorm:"primaryKey;autoIncrement:false"`
}评论
登录后参与评论
正在加载评论…
KnowForge