batchGetItem method

Future<BatchGetItemOutput> batchGetItem({
  1. required Map<String, KeysAndAttributes> requestItems,
})

Retrieves the attributes for multiple items from multiple tables using their primary keys.

The maximum number of item attributes that can be retrieved for a single operation is 100. Also, the number of items retrieved is constrained by a 1 MB the size limit. If the response size limit is exceeded or a partial result is returned due to an internal processing failure, Amazon DynamoDB returns an UnprocessedKeys value so you can retry the operation starting with the next item to get.

Amazon DynamoDB automatically adjusts the number of items returned per page to enforce this limit. For example, even if you ask to retrieve 100 items, but each individual item is 50k in size, the system returns 20 items and an appropriate UnprocessedKeys value so you can get the next page of results. If necessary, your application needs its own logic to assemble the pages of results into one set.

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

Implementation

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

  return BatchGetItemOutput.fromJson(jsonResponse.body);
}