var result struct{
User struct{
Name User.Name.Field
Email User.Email.Field
Posts []Post
}
Posts []Post
PostCount int
}
// Select a single user, the 10 first posts, and the total post count.
// .Load allows querying for anything
err := client.Load(
client.User.FindOne(
User.Name.Equals("john"),
// also get the first 5 posts of user john
User.Posts.Fetch().OrderBy(
Post.Views.Order(DESC),
).First(5).Load(),
).Select(User.Name.Select(), User.Email.Select()).Load(),
client.Post.FindMany().First(10).Load(),
client.Post.Count().Load(),
).Exec(ctx, &result)
Last active
December 3, 2019 11:58
-
-
Save steebchen/8f0d43d06361239e0c08e209f74a556f to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment