So I have an item in DynamoDB:
{
"id": "1",
"foo": "bar"
}
And I want to add a new attribute to said item, the attribute being:
{
"newAttr": [{ "bar": 1 }, { "bar": 2 }, { "bar": 3 }]
}
Now I'm doing this in JS using the AWS-SDK like so:
client.update({
ExpressionAttributeNames: { '#newAttr': 'newAttr' },
ExpressionAttributeValues: { ':newAttr': newAttr },
Key: { "id": "1" },
TableName: "foo",
UpdateExpression: "SET #newAttr = :newAttr"
}, callback)
However, I get an error:
ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: An AttributeValue may not contain an empty string for key :newAttr
So if I were to JSON.stringify(newAttr)
then it's fine, but I don't want this new attribute to be a string, I want it to be a list.
So what am I doing wrong?