DeleteItem method
Written by
Updated at February 10, 2023
Deletes a table item by the specified primary key.
You can set a condition. An item will then be deleted only if the condition is met.
The method may return the attribute values as they were before the item was deleted.
Request
The request contains data in JSON format.
{
"ConditionalOperator": "string",
"ConditionExpression": "string",
"Expected": {
"string" : {
"AttributeValueList": [
{
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
],
"ComparisonOperator": "string",
"Exists": boolean,
"Value": {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
}
},
"ExpressionAttributeNames": {
"string" : "string"
},
"ExpressionAttributeValues": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"Key": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"ReturnConsumedCapacity": "string"
"ReturnValues": "string",
"TableName": "string"
}
Parameters
Parameter | Description |
---|---|
Key |
An associative array of attribute names for AttributeValue objects, representing the primary key of the item to delete.For a simple primary key, you only need to specify its value. For a composite primary key, specify the value of a partition key and a sort key. Type: String Length: 1 - 65535 characters. Required: Yes |
TableName |
Name of the table to delete the item from.May contain a path in the directory hierarchy like path/to/table Type: String Length: 3 - 255 characters Pattern: [a-zA-Z0-9_.-]+ Required: Yes |
ConditionExpression |
Condition for deleting the item. The entry is deleted only if the condition is met. The condition consists of:
Type: String Required: No |
ExpressionAttributeNames |
Placeholder that can be used in an expression instead of an attribute name. The placeholder must start with the hash character # .Possible use cases:
Percentile attribute is in conflict with a reserved word and cannot be explicitly used in an expression. To get around this problem, in the ExpressionAttributeNames parameter, specify the placeholder: {"#P":"Percentile"} . Then, instead of the real attribute name, use #P .Type: String Length: 1 - 65535 characters. Required: No |
ExpressionAttributeValues |
Placeholder that can be used in an expression instead of an attribute value, similar to ExpressionAttributeNames . The placeholder must start with a colon : .For example, you need to check whether the value of the ProductStatus attribute was one of the following: Available | Backordered | Discontinued . To do this, first declare placeholders: { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} } . After that, you can use them in the expression: ProductStatus IN (:avail, :back, :disc) Type: String of the AttributeValue typeRequired: No |
ReturnConsumedCapacity |
Indicates whether to return information about the consumed capacity.
Type: String Possible values: TOTAL | NONE Required: No |
ReturnValues |
Use it if you need to get attributes of an item before and after its update. Possible values:
Type: String Required: No |
Response
If successful, HTTP code 200 is returned.
The response is returned in JSON format.
{
"Attributes": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"ConsumedCapacity": {
"CapacityUnits": number,
"GlobalSecondaryIndexes": {
"string" : {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
}
},
"LocalSecondaryIndexes": {
"string" : {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
}
},
"ReadCapacityUnits": number,
"Table": {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
},
"TableName": "string",
"WriteCapacityUnits": number
}
}
Parameters
Parameter | Description |
---|---|
Attributes |
An associative array of the AttributeValue type containing the item's representation before it was deleted.Returned only if the request passed the ReturnValues parameter set to ALL_OLD .Type: Associative array of the AttributeValue typeLength: 1 - 65535 characters. |
ConsumedCapacity |
Capacity units consumed by a delete operation. Returned only if the ReturnConsumedCapacity parameter set to TOTAL is specified in the request.Type: Object of the ConsumedCapacity type. |
Errors
Parameter | Description |
---|---|
ConditionalCheckFailedException |
Failed to evaluate the condition specified in the operation. HTTP status code: 400 |
InternalServerError |
An internal error occurred on the server side. HTTP status code: 500 |
ItemCollectionSizeLimitExceededException |
Item collection size limit exceeded. This exception is only returned for tables with one or more local secondary indexes. HTTP status code: 400 |
ProvisionedThroughputExceededException |
You're sending requests too often. Try to increase the interval between requests. If their number is not too large, Managed Service for YDB tries to process them all. HTTP status code: 400 |
RequestLimitExceeded |
The bandwidth exceeds the set quota. HTTP status code: 400 |
ResourceNotFoundException |
The specified table doesn't exist. HTTP status code: 400 |
TransactionConflictException |
The operation is rejected as a different transaction is in progress for the item. HTTP status code: 400 |
There may be common errors as well. These are errors that are common to all methods.