How can I create in DyanamoDB a table with AttributeType Set, Map or JSON. I don't want to create the table structure by insertion (PutItem) or update of data because I need to create an index that will contains the Map, List or JSON attribute in the projection. I need to do it a creation time (CreateTable). I also prefer to use AWS CLI. Below a sample:
{
TableName : "Music",
KeySchema: [
{
AttributeName: "Artist",
KeyType: "HASH", //Partition key
}
],
AttributeDefinitions: [
{
AttributeName: "Artist",
AttributeType: "S"
},
{
AttributeName: "instruments"
AttributeType: // Map or List or JSON type
}
],
... }
You can store a JSON document as an attribute in a DynamoDB table. To do this, use the withJSON method of Item . This method parses the JSON document and maps each element to a native DynamoDB data type.
CreateTable – Creates a new table. Optionally, you can create one or more secondary indexes, and enable DynamoDB Streams for the table. DescribeTable – Returns information about a table, such as its primary key schema, throughput settings, and index information.
While creating the DynamoDB table, you can define only the attributes that are part of the key definitions. In other words, you can define the hash key and sort key attributes only when you create the DynamoDB table. The hash and sort key attribute must be a scalar attribute.
The document and set data types cannot be part of the key attribute. Also, you can't create the index on these attribute types.
Scalar Types – A scalar type can represent exactly one value. The scalar types are number, string, binary, Boolean, and null.
Document Types – A document type can represent a complex structure with nested attributes—such as you would find in a JSON document. The document types are list and map.
Set Types – A set type can represent multiple scalar values. The set types are string set, number set, and binary set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With