Created
October 2, 2021 20:51
-
-
Save mkock/f17d772d13b63827391b6e39777fca87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type UserRepository struct { } | |
func (u *UserRepository) Load(id uint32, h Hydrater) error { | |
row := ... // Run a SELECT by id and retrieve the result in a database.Row. | |
return h.Hydrate(row) // h must be a pointer. | |
} | |
type User struct { | |
ID uint32 | |
Name string | |
// Other fields... | |
} | |
func (u *User) Hydrate(row database.Row) error { | |
return row.Scan(u) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment