If you were to create a new item and leave an empty list (i.e { a: 'string', b: [] } in your params, it'll convert this to a List Attribute. What I actually want is a String Set Attribute, or SS.
I scoured through the documentation more and found createSet and was hopeful this will solve my problem. But unfortunately it created a Map Attribute instead. Currently, this is how I'm creating it:
const aws = require('aws-sdk');
(async () => {
const docClient = new aws.DynamoDB.DocumentClient();
const params = {
TableName: 'some_table_in_dynamodb',
Item: {
a: 'some string',
b: docClient.createSet([])
}
};
const response = await docClient.put(params).promise();
console.log(response);
})();
I got the solution from playing with the UI on DynamoDB: The list CANNOT be empty, otherwise it'll convert it to a Map attribute. to fix this, just add an empty string.
const aws = require('aws-sdk');
(async () => {
const docClient = new aws.DynamoDB.DocumentClient();
const params = {
TableName: 'some_table_in_dynamodb',
Item: {
a: 'some string',
b: docClient.createSet(['']) // ADD STRING FOR SS ATTRIBUTE
}
};
const response = await docClient.put(params).promise();
console.log(response);
})();