Reputation: 11690
According this doc, DynamoDB supports map (M) and list (L) types, but when I'm trying to create a table with (L) type, I'm getting an error:
ValidationException (client): 1 validation error detected: Value 'L' at 'attributeDefinitions.2.member.attributeType' failed to satisfy constraint: Member must satisfy enum value set: [B, N, S]
It is happening after adding ThreadReplyIds
attribute to a Table info:
[
'AttributeDefinitions' => [
[
'AttributeName' => 'UserId',
'AttributeType' => 'N',
],
[
'AttributeName' => 'ThreadReplyIds', // <<---
'AttributeType' => 'L',
],
[
'AttributeName' => 'Title',
'AttributeType' => 'S',
],
],
'KeySchema' => [
[
'AttributeName' => 'UserId',
'KeyType' => 'HASH',
],
[
'AttributeName' => 'Title',
'KeyType' => 'RANGE',
],
],
'ProvisionedThroughput' => [
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5,
],
'TableName' => 'Thread',
]
My goal is to store a list or set of integer values for ThreadReplyIds
.
What am I doing wrong?
Upvotes: 3
Views: 8068
Reputation: 2758
At first, I thought it might be the version of the SDK that you are using. But after some reading through the documentation, it seems that when creating a table, the AttributeType for any AttributeDefinition can only be one of 'S|N|B' (meaning 'String', 'Number', or 'Binary'). Reference: PHP SDK DynamoDB AttributeDefinition.
This makes sense, since you can't use a List in your KeySchema anyway. It is therefore unnecessary to define an Attribute for your List when creating the table. You can always add this Attribute to whatever data you want when Putting or Updating Items in your table after it has been created. See here: PHP SDK DynamoDB PutItem
Upvotes: 11