pg
pg copied to clipboard
How to write your own join query on associations
Will I be able to make my own Joins query and somehow go-pg can map the fields to the corresponding model?
err := ecrawler.DB2.Model(&products).
Column("product.*").
Joins("variants on ....").
Joins("options on ...").
Joins("attributes on ...").
Joins("attribute_values on ....").
Where("product.id IN (?)", gopg.In(chunk)).
Select()
I tried but my products having empty associations (products[0].Variants = nil, products[0].Attributes = nil)