Good morning,
I have the following structures:
/*
* User
*/
type User struct {
ID uint 'gorm:"primary_key" json:"id'
Name string 'json:"name"'
Email string 'json:"email"'
Password string 'json:"password"'
JobpositionID uint 'json:"jobposition_id"'
CreatedAt *time.Time 'json:"created_at"'
UpdatedAt *time.Time 'json:"updated_at"'
DeletedAt *time.Time 'json:"deleted_at"'
}
/*
* Job position
*/
type Jobposition struct {
ID uint 'gorm:"primary_key" json:"id'
Name string 'gorm:"unique" json:"name"'
Description string 'json:"description"'
CreatedAt *time.Time 'json:"created_at"'
UpdatedAt *time.Time 'json:"updated_at"'
DeletedAt *time.Time 'json:"deleted_at"'
}
But I do not have any ideas on how to make associations in Golang using GORM, what I want to do is to execute the following query
SELECT * FROM Users u INNER JOIN Jobposition j ON j.id = u.JobpositionID
I would appreciate any help. Greetings