Hi,
I designed an app that depends on DB entity and repository as shown below. However, I am not sure if my design is acceptable as far as Golang goes?
Thanks
Usage
repo := repository{// db goes here}
.... := repo.findOneByID(// uuid goes here)
.... := repo.insert(// entity goes here)
entity.go
package user
type entity struct {
uuid string
name string
}
repository.go
package user
type repository struct {
db *sql.DB
}
func (r repository) findOneByID(id string) (*entity, err) {
// Execute `SELECT` query here
// ...
return entity, err
}
func (r repository) insert(e *entity) (string, error) {
// Execute `INSERT` query here
// ...
return uuid, err
}