-
|
How to scan func main() {
q := p.SELECT(
t.Animal.Name,
p.SELECT_JSON_ARR(t.AnimalTag.Name).
FROM(t.AnimalTag).
WHERE(t.AnimalTag.AnimalID.EQ(t.Animal.ID)).
AS("tags"),
).
FROM(t.Animal).
WHERE(t.Animal.ID.EQ(p.Int64(1)))
var dest struct {
model.Animal
Tags []model.AnimalTag `json_column:"tags"`
}
if err := pgxV5.Query(ctx, q, pool, &dest); err != nil {
log.Fatal(err)
}
fmt.Println(dest)
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah, you'll need to implement |
Beta Was this translation helpful? Give feedback.
Yeah, you'll need to implement
Scanmethod. Its one of the issues with pgx. I didn't find a good way to get a raw bytes from the driver. The driver by default always returnsmap[string]interface{}.