複合主鍵

設定多個欄位作為主鍵,會建立複合主鍵,例如

type Product struct {
ID string `gorm:"primaryKey"`
LanguageCode string `gorm:"primaryKey"`
Code string
Name string
}

注意 預設情況下,整數 PrioritizedPrimaryField 會啟用 AutoIncrement,若要停用,您需要關閉 int 欄位的 autoIncrement

type Product struct {
CategoryID uint64 `gorm:"primaryKey;autoIncrement:false"`
TypeID uint64 `gorm:"primaryKey;autoIncrement:false"`
}

白金贊助商

金牌贊助商

白金贊助商

金牌贊助商