Question

I recently decided to try out amazon-dynamodb and still trying to get a hold of it.

In my use-case, i have to store two variables which have same values as a string list ("SS") in an item to DynamoDB. When i tried to do that, this is what i'm getting

[ValidationException: One or more parameter values were invalid: Input collection [X,X] contains duplicates.]
message: 'One or more parameter values were invalid: Input collection [X, X] contains duplicates.',
code: 'ValidationException',
time: Fri Apr 25 2014 20:38:21 GMT+0000 (UTC),
statusCode: 400

My question: Is there a way to store duplicate values in an item's list?

Any knowledge regarding this will be appreciated.

Était-ce utile?

La solution

No, the String "list" is actually "set". If you are trying to add a list of values with duplicates, it will give you such an exception; if you are trying to add values that are already in the set, it will succeed silently.

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModel.DataTypes

Autres conseils

In DynamoDB the Hash Key, or Hash Key + Range Key combination must be unique.

On a Hash Key (id) Only Table, id must be unique.

id      
--------
john    
mary    
jane    

On a Hash Key (id) + Range Key (timestamp) Table, combination of id + timestamp must be unique

id      | timestamp
--------|-------------------------
john    | 2014-04-28T07:53:29.000Z
john    | 2014-04-28T08:53:29.000Z
john    | 2014-04-28T09:53:29.000Z
mary    | 2014-04-28T07:53:29.000Z
jane    | 2014-04-28T07:53:29.000Z

If your table has a Hash Key whose type is a String Set, then DynamoDB expects the values of the String Set to be unique as well.

id (String Set)     
------------------------
["john"]
["mary"]
["jane"]
["john", "mary"]    
["john", "jane"]
["john", "jane", "mary"]

Therefore, if you are trying to achieve the following below, if can be done because each combination is unique.

id (String Set)     
----------------
["john", "mary"]
["john", "jane"]

But if you are trying to achieve the following below, then an exception will occur:

id (String Set)     
----------------
["john", "mary"]
["john", "mary"]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top