I have a simple small table which I just want to update. Spent hours in the docs and testing things out, can't figure it out.
My table:
|environment |who|
-------------------
|ax |tom|
Primary key is on 'environment'
All I want to do is to set 'who' to 'ben' where 'environment' = 'ax'.
I have tried both the legacy way of doing things, and the expression way. I also tried both the square brackets notation AWS uses in their docs, and the array() notation of php. Below are some of the ways I've tried doing it.
1:
$result = $client->updateItem(array(
'ConditionExpression' => 'environment = :env',
'ExpressionAttributeValues' => array(
':env' => array(
'S' => 'environment'
),
':who' => array(
'S' => $who
)
),
'Key' => array( // REQUIRED
':env' => array(
'S' => $env
)
),
'ReturnValues' => 'UPDATED_NEW',
'TableName' => 'areas',
'UpdateExpression' => 'SET who = :who'
));
2:
$result = $client->updateItem([
'ConditionExpression' => 'environment = :env',
'ExpressionAttributeValues' => [
':env' => [
'S' => 'environment'
],
':who' => [
'S' => $who
]
],
'Key' => [
':env' => [
'S' => $env
]
],
'ReturnValues' => 'UPDATED_NEW',
'TableName' => 'areas',
'UpdateExpression' => 'SET who = :who'
]);
3:
$result = $client->updateItem(array(
'AttributeUpdates' => array(
'who' => array(
'Action' => 'PUT',
'Value' => array(
'S' => $who
)
)
),
'Key' => array(
'environment' => array(
'S' => $env
)
),
'TableName' => 'areas'
));
Edit: This is the error I'm getting:
SerializationException (client): Start of list found where not expected - {"__type":"com.amazon.coral.service#SerializationException","Message":"Start of list found where not expected"}'
Any help with this is much appreciated.