# 復合主鍵
通過將多個字段設為主鍵,以創建復合主鍵,例如:
```go
type Product struct {
ID string `gorm:"primaryKey"`
LanguageCode string `gorm:"primaryKey"`
Code string
Name string
}
```
**注意**默認情況下,整形`PrioritizedPrimaryField`啟用了`AutoIncrement`,要禁用它,您需要為整形字段關閉
`autoIncrement`:
```go
type Product struct {
CategoryID uint64 `gorm:"primaryKey;autoIncrement:false"`
TypeID uint64 `gorm:"primaryKey;autoIncrement:false"`
}
```