skip to Main Content

Postgresql – gorm preload loads duplicated values for many to many relation

i have a many to many relation like a customers and orders. type EmployeeShiftList struct { ID uint UUID uuid.UUID `gorm:"<-:create"` FirstName string `validate:"required,max=250"` LastName string `validate:"omitempty,max=250"` ShiftMaps []ShiftMap `gorm:"many2many:attendance.employee_shifts;foreignKey:ID;References:ShiftID;joinForeignKey:EmployeeID;joinReferences:ShiftID"} type ShiftMap struct { ShiftID uint `gorm:"primaryKey"` FromDate time.Time ToDate…

VIEW QUESTION

Postgresql – GORM Many-to-Many Relationship Not Creating Join Table Entries

this is what my playlist and user's models looks like type Playlist struct { ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` Title string `json:"title" gorm:"not null"` // Many 2 many with Back Reference…

VIEW QUESTION
Back To Top
Search