Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres Joins OneToMany not mapping #542

Open
Fyb3roptik opened this issue Jan 9, 2020 · 0 comments
Open

Postgres Joins OneToMany not mapping #542

Fyb3roptik opened this issue Jan 9, 2020 · 0 comments

Comments

@Fyb3roptik
Copy link

Fyb3roptik commented Jan 9, 2020

I am trying to do a join query and have it map correctly to my struct:

type ExerciseCms struct {
	Uuid          string  `db:"uuid" json:"uuid"`
	Timestamp     int64   `db:"timestamp" json:"timestamp"`
	Object        string  `db:"object" json:"object"`
	Audio         *Asset  `db:"-" json:"audio"`
	Image         *Asset  `db:"-" json:"image"`
	Video         *Asset  `db:"-" json:"video"`
	Assets        []*Asset `db:"-" json:"assets,omitempty"`
}

res = db.Select("exercises.*", "assets").From("exercises").LeftJoin("assets").On("exercises.uuid = assets.exercise_uuid")
err = res.All(&exercises)
// Log is done in a loop
log.Println("DEBUG: ", e.Assets)

Produces:

DEBUG:  []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant