executeTransaction method

Future<ExecuteTransactionOutput> executeTransaction({
  1. required List<ParameterizedStatement> transactStatements,
  2. String? clientRequestToken,
})

This operation allows you to perform transactional reads or writes on data stored in DynamoDB, using PartiQL.

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

Parameter transactStatements : The list of PartiQL statements representing the transaction to run.

Parameter clientRequestToken : Set this value to get remaining results, if NextToken was returned in the statement response.

Implementation

Future<ExecuteTransactionOutput> executeTransaction({
  required List<ParameterizedStatement> transactStatements,
  String? clientRequestToken,
}) async {
  ArgumentError.checkNotNull(transactStatements, 'transactStatements');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    36,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.ExecuteTransaction'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TransactStatements': transactStatements,
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
    },
  );

  return ExecuteTransactionOutput.fromJson(jsonResponse.body);
}