Original post

Hello everyone

I am trying to customize many2many table join. I have two tables from which I want to have taken the ids and want another field, which will tell me when the entry in the join table was made. The ids are coming fine, but the creation_at is not updating and shows Null instead of time.

// this is the table join struct which I want to make

type UserChallenges struct {


CreatedAt   time.Time

UserID      int

ChallengeID int


//hook before create

func (UserChallenges) BeforeCreate(Db *gorm.DB) error {

Db.SetJoinTableHandler(&User{}, "ChallengeId", &UserChallenges{})

return nil


This is not giving any error on the build. Please tell me what I am missing so that I can get the creation time field in this.PS – The documentation of GORM on gorm.io is still showing SetupJoinTable method but it is deprecated in the newer version.