Database Reference
In-Depth Information
The updateItem method
The updateItem API allows us to perform multiple operations, such as add a new at-
tribute to an item, add an extra value to an existing set of attribute values, and delete an at-
tribute from an existing item. It can be used as shown in the following code:
$response = $client->updateItem(array(
"TableName" => "Book",
"Key" => array(
"bookId" => array(
Type::NUMBER => 2001
)
),
"AttributeUpdates" => array(
"authors" => array(
"Action" => AttributeAction::PUT,
"Value" => array(
Type::STRING_SET => array("XYZ", "PQR")
)
),
"chapters" => array(
"Action" => AttributeAction::ADD,
"Value" => array(
Type::NUMBER => 2
)
),
"pages" => array(
"Action" => AttributeAction::DELETE
)
)
));
In the previous code snippet, we first added two extra authors in the authors attribute,
increased the number of chapters by 2, and then deleted attribute pages from the
item with bookId 2001.
Search WWH ::




Custom Search