transactGetItems method

Future<TransactGetItemsOutput> transactGetItems({
  1. required List<TransactGetItem> transactItems,
  2. ReturnConsumedCapacity? returnConsumedCapacity,
})

TransactGetItems is a synchronous operation that atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and Region. A TransactGetItems call can contain up to 25 TransactGetItem objects, each of which contains a Get structure that specifies an item to retrieve from a table in the account and Region. A call to TransactGetItems cannot retrieve items from tables in more than one AWS account or Region. The aggregate size of the items in the transaction cannot exceed 4 MB.

DynamoDB rejects the entire TransactGetItems request if any of the following is true:

  • A conflicting operation is in the process of updating an item to be read.
  • There is insufficient provisioned capacity for the transaction to be completed.
  • There is a user error, such as an invalid data format.
  • The aggregate size of the items in the transaction cannot exceed 4 MB.

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

Parameter transactItems : An ordered array of up to 25 TransactGetItem objects, each of which contains a Get structure.

Parameter returnConsumedCapacity : A value of TOTAL causes consumed capacity information to be returned, and a value of NONE prevents that information from being returned. No other value is valid.

Implementation

Future<TransactGetItemsOutput> transactGetItems({
  required List<TransactGetItem> transactItems,
  ReturnConsumedCapacity? returnConsumedCapacity,
}) async {
  ArgumentError.checkNotNull(transactItems, 'transactItems');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.TransactGetItems'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TransactItems': transactItems,
      if (returnConsumedCapacity != null)
        'ReturnConsumedCapacity': returnConsumedCapacity.toValue(),
    },
  );

  return TransactGetItemsOutput.fromJson(jsonResponse.body);
}