Let say I have a table named PEOPLE which store rows of Person. However, the Person contains slice, struct and slice of struct, i.e. the Superpower, Vehicle and FriendList fields respectively.
How should I store and retrieve those values in Postgresql with Golang? I can't find any practical tutorial related to this problem. Use custom data types, or JSON, or ORM method, or building custom functions to deal with these? Many opinions out there, but I still can't figure out a working way to solve this problem, please help.
I am using Ozzo-dbx , however, any solutions is welcome.
Can someone provides a working example? Sorry if this newbie question irritates you, but I already tried for few days, and keep failing... (T_T)
type Transport struct {
Brand string
Size int
}
type Friend struct {
Name string
IsProgrammer bool
}
type Person struct {
ID int
Name string
Superpower []string //slice
Vehicle Transport //struct
FriendList []Friend //slice of struct
}
slice,structandslice of structvalues in JSON format, and other valuesas is(soIDasint,Nameasstringetc). It will be logical :)SELECT Person.Vehicle.Brand ..., then this may beautifully implemented... is it possible? :)