ent/doc: add example for select api

Reviewed By: dlvhdr

Differential Revision: D17183384

fbshipit-source-id: 39072346582a70b74f9eb78137a9f9357117ca84
This commit is contained in:
Ariel Mashraki
2019-09-04 08:18:35 -07:00
committed by Facebook Github Bot
parent 95d878d3c6
commit b26334c93c

View File

@@ -199,6 +199,32 @@ users, err := a8m.
QueryPets().
All(ctx)
```
Get all pet names.
```go
names, err := client.Pet.
Query().
Select(pet.FieldName).
Strings(ctx)
```
Get all pet names and ages.
```go
var v []struct {
Age int `json:"age"`
Name string `json:"name"`
}
err := client.Pet.
Query().
Select(pet.FieldAge, pet.FieldName).
Scan(ctx, &v)
if err != nil {
log.Fatal(err)
}
```
More advance traversals can be found in the [next section](traversals.md).
## Delete One