deleteItem method
Future<DeleteItemOutput>
deleteItem({
- required Key key,
- required String tableName,
- Map<
String, ExpectedAttributeValue> ? expected, - ReturnValue? returnValues,
Deletes a single item in a table by primary key.
You can perform a conditional delete operation that deletes the item if it exists, or if it has an expected attribute value.
May throw ConditionalCheckFailedException. May throw ProvisionedThroughputExceededException. May throw ResourceNotFoundException. May throw LimitExceededException. May throw RequestLimitExceeded. May throw InternalServerError.
Parameter tableName
:
The name of the table in which you want to delete an item. Allowed
characters are a-z
, A-Z
, 0-9
,
_
(underscore), -
(hyphen) and .
(period).
Implementation
Future<DeleteItemOutput> deleteItem({
required Key key,
required String tableName,
Map<String, ExpectedAttributeValue>? expected,
ReturnValue? returnValues,
}) async {
ArgumentError.checkNotNull(key, 'key');
ArgumentError.checkNotNull(tableName, 'tableName');
_s.validateStringLength(
'tableName',
tableName,
3,
255,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'DynamoDB_20111205.DeleteItem'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Key': key,
'TableName': tableName,
if (expected != null) 'Expected': expected,
if (returnValues != null) 'ReturnValues': returnValues.toValue(),
},
);
return DeleteItemOutput.fromJson(jsonResponse.body);
}