Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions firestore/save_data_batch_writes.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
)

func batchWrite(ctx context.Context, client *firestore.Client) error {
// Get a new write batch.
batch := client.Batch()
// Get a new write bulk.
batch := client.BulkWriter(ctx)

// Set the value of "NYC".
nycRef := client.Collection("cities").Doc("NYC")
Expand All @@ -43,14 +43,10 @@ func batchWrite(ctx context.Context, client *firestore.Client) error {
laRef := client.Collection("cities").Doc("LA")
batch.Delete(laRef)

// Commit the batch.
_, err := batch.Commit(ctx)
if err != nil {
// Handle any errors in an appropriate way, such as returning them.
log.Printf("An error has occurred: %s", err)
}

return err
// Flush the bulk.
batch.Flush()

return nil
}

// [END firestore_data_batch_writes]