batchWriteItem method

Future<BatchWriteItemOutput> batchWriteItem({
  1. required Map<String, List<WriteRequest>> requestItems,
})

Allows to execute a batch of Put and/or Delete Requests for many tables in a single call. A total of 25 requests are allowed.

There are no transaction guarantees provided by this API. It does not allow conditional puts nor does it support return values.

May throw ProvisionedThroughputExceededException. May throw ResourceNotFoundException. May throw LimitExceededException. May throw RequestLimitExceeded. May throw InternalServerError.

Parameter requestItems : A map of table name to list-of-write-requests. Used as input to the BatchWriteItem API call

Implementation

Future<BatchWriteItemOutput> batchWriteItem({
  required Map<String, List<WriteRequest>> requestItems,
}) async {
  ArgumentError.checkNotNull(requestItems, 'requestItems');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20111205.BatchWriteItem'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'RequestItems': requestItems,
    },
  );

  return BatchWriteItemOutput.fromJson(jsonResponse.body);
}