googleapis / googleapis/google-cloud-go

how to get bulkWriter result?

Open
#13,326 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

```go
bw := client.BulkWriter(context.Background())
defer bw.End()

wg := sync.WaitGroup{}

for i := 0; i < 5; i++ {
docRef := client.Collection("test").Doc(fmt.Sprintf("test_%d", i))
wg.Add(1)
body := map[string]interface{}{"id": fmt.Sprintf("test_%d", i)}
job, err := bw.Create(docRef, body)
if err != nil {
logx.Severef("write fail %v", err)
} else {
// is this a right way?
go func() {
defer wg.Done()
res, err := job.Results()
logx.Info(err)
logx.Info(res)
}()
}
}

# who is in behind
# bw.End()
# wg.Wait()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.