batchWrite method

  1. @override
Future<BatchWriteResponse> batchWrite(
  1. BatchWriteRequest request
)
override

Applies a batch of write operations.

The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write.

If you require an atomically applied set of writes, use Commit instead.

Throws a http.ClientException if there were problems communicating with the API service. Throws a ServiceException if the API method failed for any reason.

Implementation

@override
Future<BatchWriteResponse> batchWrite(BatchWriteRequest request) async {
  if (isClosed) throw StateError('Service is closed');

  if (_batchWrite case final batchWrite?) {
    return batchWrite(request);
  }
  throw UnsupportedError('batchWrite');
}