I have two struct:
type User struct {
Id uint32
First string
Last string
Adds []Address
}
type Address struct {
Id uint32
Location string
}
And i have two table:
create table user (
Id INT UNSIGNED NOT NULL AUTO_INCREMENT,
First VARCHAR(40) NULL,
Last VARCHAR(40) NULL,
PRIMARY KEY (Id)
);
create table address (
Id INT UNSIGNED NOT NULL AUTO_INCREMENT,
UserId INT UNSIGNED NOT NULL,
Location VARCHAR(400) NOT NULL,
FOREIGN KEY (UserId) REFERENCES user (Id),
PRIMARY KEY (Id)
);
"address" table has one to many relationship with "user" table. so how can i fetch data from these two table with inner join and save it in "user" struct instance?
Note: Without gorm or other orm library?