Delete Records

RemoveResult remove(RemoveRequest request)

Function

Removes a record of the table, and can remove all or part of the attributes, or specify the conditions, and removal becomes successful only when the conditions are met

Consumes one unit of write quota, and if a condition is met, one unit of read quota is also consumed (in addition, if an EAGER-type secondary index is created, each Eager secondary index needs 1 additional read quota)

Method parameters

request : RemoveRequest : required

RemoveRequest includes the following sections

1.tableName : String : required

Specifies which table records to remove

2.keys : Map< String, Datum > : required

Specifies which line to remove, ie the entity group key for that row (if any) and the attribute value of the primary key; keys must contain all entity group keys (if any) and the primary key attributes

3.attributes : List< String > : optional

The attribute list to be removed is not specified to indicate that the entire record is removed. When some attributes are removed, the record still exists even if all the attributes have been deleted, and the entire record needs to be explicitly deleted if it is to be deleted

4.condition : SimpleCondition : optional

Specifies the condition of successful deletion, ie it can be successfully deleted when the condition is met, which is the check and set semantics of the atom

The condition may include: specifying that an attribute of the row is greater than, greater than or equal to, equal to, less than or equal to, less than a certain value, or whether the line already exists

Method return value

removeResult : RemoveResult

removeResult is only success's one boolean value that indicates if removing is successful or not

If the invocation times out, it cannot be determined whether the record has been removed or not

Exception error code

INTERNAL_ERROR(1): Server exception

ACCESS_DENIED(4): User does not have write permission for this table

VALIDATION_FAILED(5): keys do not completely contain the entity group key (if any) and the primary key attributes, or the specified attribute does not exist, or the row specified in the condition does not exist

THROUGHPUT_EXCEED(8): The current read/write speed has exceeded the read/write quota for this table

RESOURCE_NOT_FOUND(9): Specified table does not exist

Limitation

keys must contain the entity group key (if any) and the attributes of the primary key

Example

With the Example table, the sample code for removing data is provided below

$tableName = 'php-note';
$remove = new RemoveRequest(array(
    "tableName" => $tableName,
    "keys" => array(
        "userId" => DatumUtil::datum("user1"),
        "noteId" => DatumUtil::datum(0),
    )
));
$tableClient->remove($remove);

results matching ""

    No results matching ""