mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/doc: fix getting-started doc example
Reviewed By: dlvhdr Differential Revision: D17735319 fbshipit-source-id: f90311d94a189d911b62ab972ac98982a623271b
This commit is contained in:
committed by
Facebook Github Bot
parent
6d159024e7
commit
c4527afbaf
@@ -583,17 +583,18 @@ Now when we have a graph with data, we can run a few queries on it:
|
||||
"<project>/ent/group"
|
||||
)
|
||||
|
||||
func Do(context context.Context, client *ent.Client) {
|
||||
groups, err := client.Group.
|
||||
Query().
|
||||
Where(group.HasUsers()).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
log.Fatal("failed getting groups:", err)
|
||||
}
|
||||
log.Println("groups returned:", cars)
|
||||
// Output: (Group(Name=GitHub), Group(Name=GitLab),)
|
||||
}
|
||||
func QueryGroupWithUsers(ctx context.Context, client *ent.Client) error {
|
||||
groups, err := client.Group.
|
||||
Query().
|
||||
Where(group.HasUsers()).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting groups: %v", err)
|
||||
}
|
||||
log.Println("groups returned:", groups)
|
||||
// Output: (Group(Name=GitHub), Group(Name=GitLab),)
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
The full example exists in [GitHub](https://github.com/facebookincubator/ent/tree/master/examples/start).
|
||||
|
||||
Reference in New Issue
Block a user