executeStatement method

Future<ExecuteStatementOutput> executeStatement({
  1. required String statement,
  2. bool? consistentRead,
  3. String? nextToken,
  4. List<AttributeValue>? parameters,
})

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

May throw ConditionalCheckFailedException. May throw ProvisionedThroughputExceededException. May throw ResourceNotFoundException. May throw ItemCollectionSizeLimitExceededException. May throw TransactionConflictException. May throw RequestLimitExceeded. May throw InternalServerError. May throw DuplicateItemException.

Parameter statement : The PartiQL statement representing the operation to run.

Parameter consistentRead : The consistency of a read operation. If set to true, then a strongly consistent read is used; otherwise, an eventually consistent read is used.

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

Parameter parameters : The parameters for the PartiQL statement, if any.

Implementation

Future<ExecuteStatementOutput> executeStatement({
  required String statement,
  bool? consistentRead,
  String? nextToken,
  List<AttributeValue>? parameters,
}) async {
  ArgumentError.checkNotNull(statement, 'statement');
  _s.validateStringLength(
    'statement',
    statement,
    1,
    8192,
    isRequired: true,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    32768,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.ExecuteStatement'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Statement': statement,
      if (consistentRead != null) 'ConsistentRead': consistentRead,
      if (nextToken != null) 'NextToken': nextToken,
      if (parameters != null) 'Parameters': parameters,
    },
  );

  return ExecuteStatementOutput.fromJson(jsonResponse.body);
}