golang gorm reference two columns to same table, problem with insert

Issue original idea was to build rbac analog from yii https://github.com/yiisoft/yii2/blob/master/framework/rbac/migrations/schema-pgsql.sql so, i have these two models: type AuthItem struct { ID uint `gorm:"uniqueIndex;primaryKey;auto_increment;column:id" json:"id"` Name string `gorm:"uniqueIndex;primaryKey;not null;type:varchar(64);column:name" json:"name"` ItemType int64 `gorm:"type:smallint;not null;column:item_type" json:"item_type"` Description string `gorm:"size:255;column:description" json:"description"` }

Continue reading

How to access gorm.Model.ID?

Issue So gorm.Model provides some base properties or fields: ID uint `json:”-” gorm:”primary_key”` CreatedAt time.Time `json:”-“` UpdatedAt time.Time `json:”-“` DeletedAt *time.Time `json:”-” sql:”index”` and you can use it as so type User struct { gorm.Model Name string Email string `gorm:”type:varchar(100);unique_index”`

Continue reading