go-ozzo / ozzo-routing

An extremely fast Go (golang) HTTP router that supports regular expression route matching. Comes with full support for building RESTful APIs.
MIT License
455 stars 51 forks source link

Can we use this feature to populate all nested struct fields? #63

Open kolkov opened 3 years ago

kolkov commented 3 years ago

Hi! I try to find the way to populate DDD aggregate with simple joined query. At this moment it possible only by giving all needed fields in select query. I whant to use this way to populate all struct with nested struct fields at once. https://stackoverflow.com/a/13153422

For example:

type Wagon struct {
    Wagon
    State WagonState
    Location WagonLocation
}

with

...
Select(
    "w.*",
    "ws.*",
    "wl.*"
).From("wagon w").
InnerJoin("wagon_state ws", dbx.NewExp("ws.id=w.state_id")).
InnerJoin("wagon_location wl", dbx.NewExp("wl.id=w.location_id")).
...

Is it possible to add to this lib?