How to update an item in Dynamodb of type String Set (SS)?
As of September 2015, there is a createSet
function in the DocumentClient that you can use for this.
UPDATE - added example
I've modified your example code to use this function:
qw = new AWS.DynamoDB.DocumentClient();
var params = {
TableName : "myTable",
Key: {
"id": somekey
},
UpdateExpression: "set ssvar= :arrp",
ExpressionAttributeValues: {
":arrp": qw.createSet([ "test", "test2" ])
}
};
qw.update (etc.)
This is an artifact of using the DocumentClient - StringSet is not a JSON type.
The DocumentClient converts a StringSet to the Array native JavaScript type: https://github.com/aws/aws-sdk-js/blob/master/lib/dynamodb/converter.js#L61. Then the client serializes the native JavaScript Array as a DynamoDB List type: https://github.com/aws/aws-sdk-js/blob/master/lib/dynamodb/converter.js#L12.
If you want to use the StringSet type, you can use the low-level API: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html