volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.73k stars 544 forks source link

Optimize Loading Data over Foreign Keys #204

Closed jojomi closed 7 years ago

jojomi commented 7 years ago

Let's assume I have data in Table A that I want to filter with certain criteria. For any data in the result set I would like to have access to the linked data in Table B and Table C that are having foreign keys to Table A.

What is the way to achieve that using sqlboiler's generated code without calling LoadB() and LoadC() on every single item in the resultset after filtering on A?

aarondl commented 7 years ago

I think you're talking about: https://github.com/volatiletech/sqlboiler#relationships (see piece on eager loading).

There is a lack of filtering for eager-loaded entities currently. In your example you could not tell B to only come back with B that match where id > 5 or some such where clause. We are planning to somehow solve this in v3.

Re-open if this is not the solution to your issue. Thanks :)