I am new in aws dynamo db. I have read that we can set M type of attributeValue in schema of dynamo db.
But when I execute the code below
var params = {
    TableName: 'product',
    KeySchema: [
        {
            AttributeName: 'productType',
            KeyType: 'HASH'
        },
         {
            AttributeName: 'manufacturer',
            KeyType: 'SORT'
        }
    ],
    AttributeDefinitions: [
        {
            AttributeName: 'productType',
            AttributeType: 'S'
        },
         {
            AttributeName: 'manufacturer',
            AttributeType: 'M'
        }
    ],
     ProvisionedThroughput: {
        ReadCapacityUnits: 1, 
        WriteCapacityUnits: 1, 
    }
};
dynamodb.createTable(params, function(err, data) {
   console.log(err, data);
});
It keeps throwing error  {"message":"Member must satisfy enum value set: [B, N, S]","code":"ValidationException","time":"2018-02-07T11:20:12.930Z","statusCode":400,"retryable":false}
But the above link says that there is an attribute of type Map available. Can someone explain me how can I achieve Map in dynamo db.
When you create a dynamodb table, or add an index to it, you can only define the attributes for the indexes. In other words, you can only define the attributes used for a partition key or sort key. like you are doing in your example. But the only attribute types that are valid for keys are S (string), N (number), and B (binary). Maps are not valid attribute types for either partition or sort keys, so you can't use them when defining your table or index.
DynamoDB is schema-less. You don't define any attributes other than the ones for the index keys at table creation. If you want a map in your table, you simply insert one when you put or update items.
This is basically the drawback of DynamoDB , vs say MongoDB or couchbase . The other NoSQL Dbs can let you have documents of any shape and index any attribute no matter how deep it is. In DD , you don't have this flexibility - top level attributes which are indexable must be scalar . This is the trade off for speed.
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