Increment Operation

IncrementResult increment(IncrementRequest request)

Function

Creates atomic increment operation on integer properties of a row in a table

Needs to consume one unit per read/write quota

Method parameters

request : IncrementRequest : required

IncrementRequest includes the following sections

1.tableName : String : required

Specified operation table

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

Specifies which line to operate, 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.amounts : Map< String, Datum > : required

Attributes that need increment operation must be an integer and cannot be indexed

Method return value

incrementResult : IncrementResult

IncrementResult contains an amounts : Map< String, Datum >, an incremented value for the specified property

If the invocation times out, it cannot be determined whether the record has been incremented successfully

Exception error code

INTERNAL_ERROR(1): Server exception

ACCESS_DENIED(4): User does not have read/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 amounts do not exist or are not integral,

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

The attribute specified by the amounts must be an integer and cannot be an index attribute

Example

With the Example table, the sample code for increment operation is provided below

$tableName = 'php-note';
$increment = new IncrementRequest(array(
   "tableName" => $tableName,
    "keys" => array(
        "userId" => DatumUtil::datum("user1"),
        "noteId" => DatumUtil::datum(0),
    ),
    "amounts" => array(
        "version" => DatumUtil::datum(1),
    )
));
//add 1 on this line's version number
$tableClient->increment($increment);

results matching ""

    No results matching ""