-
So I have something like this: c.Team.Query().Where().WithUsers().All(ctx) How do I add a Select function that applies to the users? I see WithUsers takes arguments but I don't really know what to give it and can't find anything about it in the docs. |
Beta Was this translation helpful? Give feedback.
Answered by
a8m
Nov 7, 2022
Replies: 1 comment 1 reply
-
Hey @niwla23 👋🏻 pets, err := client.Pet.
Query().
Select(pet.FieldName).
WithOwner(func (q *ent.UserQuery) {
q.Select(user.FieldName)
}).
All(ctx) Note, there is also an example for it in our doc. Please, see: https://entgo.io/docs/crud#field-selection |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
niwla23
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @niwla23 👋🏻
You can pass functions to configure the sub-query as follows:
Note, there is also an example for it in our doc. Please, see: https://entgo.io/docs/crud#field-selection