ent supports querying entities with their associations (through their edges). The associated entities are populated to the
Edges field in the returned object.
Let's give an example of what the API looks like for the following schema:
Query all users with their pets:
Eager loading allows to query more than one association (including nested), and also filter, sort or limit their result. For example:
Each query-builder has a list of methods in the form of
With<E>(...func(<N>Query)) for each of its edges.
<E> stands for the edge name (like,
<N> for the edge type (like,
Note that, only SQL dialects support this feature.
Since a query-builder can load more than one association, it's not possible to load them using one
JOIN operation. Therefore,
ent executes additional queries for loading associations. One query for
O2O edges, and 2 queries for loading
Note that, we expect to improve this in the next versions of