Recently DynamoDB released document types (list or map). See here: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModel.DataTypes or here: http://www.allthingsdistributed.com/2014/10/document-model-dynamodb.html
Now am trying to store the following array in DynamoDB
array("key"=>"value")
I am using PHP SDK 2.7.0 and 2.7.2 and 3.0.0 beta (tried all those to solve my problem, every time the same issue). My code below which stores two strings works perfectly:
require ("aws2.7.0/aws-autoloader.php");
use Aws\DynamoDb\DynamoDbClient;
$client = DynamoDbClient::factory(array(
'key' => 'KEY',
'secret' => 'SECRET',
'region' => 'eu-west-1'
));
$result = $client->putItem(array(
'TableName' => 'requests-test',
'Item' => array(
'messageId' => array('S' => "test-message1"),
'data' => array('S' => "message-data-here"),
),
)
));
Now I am trying to store a simple array with Map data type instead of string:
require ("aws2.7.0/aws-autoloader.php");
use Aws\DynamoDb\DynamoDbClient;
$client = DynamoDbClient::factory(array(
'key' => 'KEY',
'secret' => 'SECRET',
'region' => 'eu-west-1'
));
$result = $client->putItem(array(
'TableName' => 'requests-test',
'Item' => array(
'messageId' => array('S' => "test-message1"),
'data' => array('M' => array("key"=>"value")),
),
)
));
this results in the following error:
Fatal error: Uncaught Aws\DynamoDb\Exception\DynamoDbException: AWS Error Code: SerializationException, Status Code: 400, AWS Request ID: 8H9URPVBNPCTG4VALA62XXXX3NVV4KQNSO5AEMVJF66Q9ASUAYGX, AWS Error Type: client, AWS Error Message: Expected null, User-Agent: aws-sdk-php2/2.7.0 Guzzle/3.9.2 curl/7.36.0 PHP/5.3.28 thrown in /path/aws2.7.0/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91
AWS PHP SDK 2.7.0 and above should support Map and List type: https://github.com/aws/aws-sdk-php/releases/tag/2.7.0
How can I store arrays in DynamoDB? Is it possible yet with the current SDKs out there - or do they need to release an update to fully support those new data types? Or is the issue in my code?
I'd be really grateful for any comments or possible solutions. Thanks in advance!