Tags ID of Model as unique field

This commit is contained in:
smavros 2019-08-10 22:41:43 +02:00
parent bf24fb9a8f
commit 8f5c47dde9

View file

@ -10,7 +10,7 @@ import (
// The type Model is exactly the same with gorm.Model (see jinzhu/gorm) // The type Model is exactly the same with gorm.Model (see jinzhu/gorm)
// except the json tags that are needed for serializing the models // except the json tags that are needed for serializing the models
type Model struct { type Model struct {
ID uint `json:"id" gorm:"primary_key:true"` ID uint `json:"id" gorm:"unique;primary_key:true"`
CreatedAt time.Time `json:"-"` CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-" sql:"index"` DeletedAt *time.Time `json:"-" sql:"index"`